【问题标题】:Method org.postgresql.jdbc3.Jdbc3PreparedStatement.setQueryTimeout(int) is not yet implemented.;方法 org.postgresql.jdbc3.Jdbc3PreparedStatement.setQueryTimeout(int) 尚未实现。
【发布时间】:2016-08-31 11:54:50
【问题描述】:

我是春季批次的新手。使用春季批处理作业,我在 postgres db 中插入数据,然后出现此错误。如何解决这个问题?

方法 org.postgresql.jdbc3.Jdbc3PreparedStatement.setQueryTimeout(int) 尚未实现。嵌套异常是 java.sql.SQLException:方法 org.postgresql.jdbc3.Jdbc3PreparedStatement.setQueryTimeout(int) 尚未实现。'

这是我的数据源代码。

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close">
    <!-- DB connection properties -->
    <property name="driverClass" value="${db.driver:oracle.jdbc.OracleDriver}" />
    <property name="jdbcUrl" value="${db.url}" />
    <property name="user" value="${db.user:}" />
    <property name="password" value="${db.password:}" />

    <!-- Pool sizing properties -->
    <property name="initialPoolSize" value="${db.pool.initialSize:5}" />
    <property name="maxPoolSize" value="${db.pool.maxSize:25}" />
    <property name="minPoolSize" value="${db.pool.minSize:0}" />
    <property name="maxStatements" value="${db.pool.maxStatements:10}" />

    <!-- Connection testing and acquisition properties -->
    <property name="maxIdleTime" value="${db.con.maxIdleTime:300}" />
    <property name="idleConnectionTestPeriod" value="${db.con.testPeriod:30}" />
    <property name="preferredTestQuery" value="${db.con.testQuery:select 1 from dual}" />
    <property name="acquireIncrement" value="${db.con.acquireIncrement:5}" />
    <property name="acquireRetryAttempts" value="${db.con.retryAttempts:0}" />
    <property name="acquireRetryDelay" value="${db.con.retryDelay:3000}" />

    <!-- JMX name -->
    <property name="dataSourceName" value="Datasource" />

    <!-- Debugging options -->
    <property name="unreturnedConnectionTimeout" value="${db.con.unreturnedTimeout:0}" />
    <property name="debugUnreturnedConnectionStackTraces" value="${db.con.debugUnreturned:false}" />
</bean>

【问题讨论】:

  • 我很困惑 - 为什么当您的池中有 Oracle JDBC 驱动程序类时,错误提示缺少 PostgreSQL 方法?
  • 驱动值为org.postgresql.Driver 我用的是postgres sql

标签: java spring spring-batch


【解决方案1】:

数据源看起来不错....@duffymo,Oracle 驱动程序是默认值,但如果指定了“db.driver”,则将被“db.driver”属性的值覆盖。

某些版本的 PostgreSQL 驱动程序会抛出 setTimeout 错误,因为它们实际上没有实现 setTimeout,因此他们不希望用户认为 setTimeout 实际上有任何影响。

您使用的是哪个版本的 PostreSQL 驱动程序?你能分享一下 Spring Batch 作业的一些细节吗?我不确定如何防止 Spring 在 PreparedStatement 上设置超时。猜测一下,您可以将 db.con.unreturnedTimeout 设置为 0;我在想这个值可能会传递给 setTimeout;但我不确定。

【讨论】:

  • 我尝试了不同的版本,包括最新的 9.4-1200-jdbc41。但我得到同样的错误。春季批处理版本 3.0.4.RELEASE。我尝试添加代码 ps.setQueryTimeout(0);但是错误是一样的
  • 您能分享更多有关您的 Spring Batch 配置和批处理作业的详细信息吗? Spring Batch 的数据库阅读器似乎默认将 queryTimeout 设置为 -1,而这个 -1 的值使其在preparedStatements 中根本不调用queryTimeout。您的配置或源代码中是否有任何“queryTimeout”或“query-timeout”实例?
  • 能够解决问题是在父级我使用不同版本的驱动程序。感谢您的建议
猜你喜欢
  • 2014-10-25
  • 2016-09-30
  • 1970-01-01
  • 2018-08-13
  • 2019-02-19
  • 2021-03-13
  • 1970-01-01
  • 2021-09-01
  • 1970-01-01
相关资源
最近更新 更多