sqlite-jdbc icon indicating copy to clipboard operation
sqlite-jdbc copied to clipboard

SQLitePooledConnection physical connection is exposed on statements

Open MikeNicholls opened this issue 8 years ago • 2 comments

When a proxy connection returned by SQLitePooledConnection#getConnection() is used to create a statement, the underlying physical connection is exposed on the statement. I am using a third-party library which is creating a statement and then closing the connection when it finishes by using the reference on the statement, which leaves the pooled connection in an unusable state.

ConnectionPoolDataSource ds = new SQLiteConnectionPoolDataSource();
PooledConnection pooledConn = ds.getPooledConnection();

Connection handle = pooledConn.getConnection();
handle.createStatement().getConnection().close(); // This closes the physical connection, not the proxy

Connection handle2 = pooledConn.getConnection(); // java.sql.SQLException: database connection closed

MikeNicholls avatar Jan 12 '17 22:01 MikeNicholls

Thanks for reporting. This makes sense since I observed the same issue when using HikariCP with sqlite-jdbc.

xerial avatar May 25 '18 21:05 xerial

Is this still happening on the latest version?

gotson avatar Jul 29 '22 05:07 gotson

Seems like it was actually closed by #340

gotson avatar Sep 20 '22 06:09 gotson