其他 JDBC 3.x 配置 - Amazon Athena
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

其他 JDBC 3.x 配置

以下各节旨在介绍 JDBC 3.x 驱动程序的一些其他配置设置。

网络超时

驱动程序对 Athena 进行 API 调用时等待响应的时长(以毫秒为单位)。在此时间之后,驱动程序会引发超时异常。

不能将网络超时设置为连接参数。要进行设置,请在 JDBC Connection 对象上调用 setNetworkTimeout 方法。此值可在 JDBC 连接的生命周期中更改。此参数的默认值为 infinity

以下示例将网络超时设置为 5000 毫秒。

... AthenaDriver driver = new AthenaDriver(); Connection connection = driver.connect(url, connectionParameters); connection.setNetworkTimeout(null, 5000); ...

查询超时

在提交查询后,驱动程序在 Athena 上等待查询完成的时长(以秒为单位)。在此时间之后,驱动程序会尝试取消已提交的查询并引发超时异常。

不能将查询超时设置为连接参数。要进行设置,请在 JDBC Statement 对象上调用 setQueryTimeout 方法。此值可在 JDBC 语句的生命周期中更改。此参数的默认值为 0(零)。值 0 表示查询可以一直运行直到完成(视 服务限额 而定)。

以下示例将查询超时设置为 5 秒。

... AthenaDriver driver = new AthenaDriver(); Connection connection = driver.connect(url, connectionParameters); Statement statement = connection.createStatement(); statement.setQueryTimeout(5); ...