Method org.postgresql.jdbc4.Jdbc4Statement.setQueryTimeout(int) is not yet implemented.

708 views
Skip to first unread message

Ismael Juma

unread,
Oct 8, 2014, 10:03:21 AM10/8/14
to hika...@googlegroups.com
Hi,

We have just migrated from c3p0 to HikariCP and ran into an issue[1] when using it with Amazon Redshift. Amazon recommends using the Postgres JDBC 8.4 driver[2], which has not implemented setQueryTimeout. The implementation is:

    public void setQueryTimeout(int seconds) throws SQLException
    {
        checkClosed();
        if (seconds < 0)
            throw new PSQLException(GT.tr("Query timeout must be a value greater than or equals to 0."),
                                    PSQLState.INVALID_PARAMETER_VALUE);

        if (seconds > 0)
            throw Driver.notImplemented(this.getClass(), "setQueryTimeout(int)");

        timeout = seconds;
    }

As can be seen, the only way to make this method work is to pass a value of 0. This can currently be achieved by setting `connectionTimeout` to 0, but it's not ideal.

I think it would be nice to disable `setQueryTimeout` for `isConnectionAlive` or to make it configurable separately from `connectionTimeout`. Thoughts?

Best,
Ismael

[1] org.postgresql.util.PSQLException: Method org.postgresql.jdbc4.Jdbc4Statement.setQueryTimeout(int) is not yet implemented.
at org.postgresql.Driver.notImplemented(Driver.java:753) ~[postgresql-8.4-702.jdbc4.jar:na]
at org.postgresql.jdbc2.AbstractJdbc2Statement.setQueryTimeout(AbstractJdbc2Statement.java:654) ~[postgresql-8.4-702.jdbc4.jar:na]
at com.zaxxer.hikari.pool.HikariPool.isConnectionAlive(HikariPool.java:459) [HikariCP-2.1.0.jar:na]
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:175) [HikariCP-2.1.0.jar:na]
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:94) [HikariCP-2.1.0.jar:na]

Brett Wooldridge

unread,
Oct 8, 2014, 10:11:18 AM10/8/14
to hika...@googlegroups.com
Thanks, Ismael we'll take it under consideration.  I should note that there are users who are using the postgresql-9.3 driver with Redshift successfully, but it will depend on your application.

Ismael Juma

unread,
Oct 8, 2014, 10:16:12 AM10/8/14
to hika...@googlegroups.com
On Wednesday, 8 October 2014 15:11:18 UTC+1, Brett Wooldridge wrote:
Thanks, Ismael we'll take it under consideration.  I should note that there are users who are using the postgresql-9.3 driver with Redshift successfully, but it will depend on your application.

Thank you. We were using that driver ourselves. We ran into an issue and downgraded, but it turns out that both versions were affected in the end. So, we could upgrade again, in theory. I assume that 9.3 handles `setQueryTimeout` correctly?

Best,
Ismael
Reply all
Reply to author
Forward
0 new messages