Cryptic clojure postgresql jdbc error

:exclusions :exclusions :exclusions

While we're at the Clojure/Clojurescript :exclusions game (see last post), if you get an error such as below, you may need to add

[postgresql]

to your :exclusions.

The culprit is/may be

[postgresql "8.4-702.jdbc4"]

, referenced even by the latest version of incanter, via incanter-sql (from lein deps :tree):

[incanter/incanter-sql "1.9.3"]
     [clojureql "1.0.5" :exclusions [[org.clojure/clojure]]]
       [mysql/mysql-connector-java "5.1.17"]
       [org.apache.derby/derby "10.1.1.0"]
       [org.clojure/tools.nrepl "0.2.12"]
       [org.xerial/sqlite-jdbc "3.7.2"]
       [postgresql "8.4-702.jdbc4"]

This referenced artifact recently celebrated its 11th birthday and is obviously outdated.

Of course you will have the latest jdbc lib such as

[org.postgresql/postgresql "42.2.24"]

in your dependencies, but the abovementioned [postgresql "8.4-702.jdbc4"] may take precedence under some hard to reproduce circumstances when not excluded explicitly.

Here's the a sample error trace:

2021-10-20 20:20:57 WARN  BasicResourcePool:223 - com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@55a7f0c4 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: 
org.postgresql.util.PSQLException: This ResultSet is closed.
        at org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed(AbstractJdbc2ResultSet.java:2674)
        at org.postgresql.jdbc2.AbstractJdbc2ResultSet.setFetchSize(AbstractJdbc2ResultSet.java:1791)
        at org.postgresql.jdbc4.Jdbc4Statement.createResultSet(Jdbc4Statement.java:39)
        at org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler.handleResultRows(AbstractJdbc2Statement.java:209)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1747)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:498)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:372)
        at org.postgresql.jdbc2.AbstractJdbc2Connection.execSQLUpdate(AbstractJdbc2Connection.java:262)
        at org.postgresql.jdbc2.AbstractJdbc2Connection.getTransactionIsolation(AbstractJdbc2Connection.java:739)
        at com.mchange.v2.c3p0.impl.NewPooledConnection.<init>(NewPooledConnection.java:120)
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:240)
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176)
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163)
        at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
        at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908)
        at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
2021-10-20 20:20:57 WARN  BasicResourcePool:220 - Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@5ddd3fbd is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
Execution error (PSQLException) at org.postgresql.jdbc2.AbstractJdbc2ResultSet/checkClosed (AbstractJdbc2ResultSet.java:2674).
This ResultSet is closed.

Hope it helps.

Posted: 20 October 2021

comments powered by Disqus