pgjdbc-ng icon indicating copy to clipboard operation
pgjdbc-ng copied to clipboard

ResultSetDelegator for PGStatementDelegator

Open BeateSchatzmann opened this issue 4 years ago • 1 comments

I use Apache's connection pool implementation "Apache Commons DBCP" (commons-dbcp2). In their connection pool (SharedPoolDataSource) I have to set a ConnectionPoolDataSource and I want to use com.impossibl.postgres.jdbc.PGConnectionPoolDataSource - because I really like that PGPooledConnection removes connections from the pool after a fatal SQLException. Now I use a lot of code that creates a ResultSet and in the end not only the ResultSet is closed but also the Statement that ResultSet.getStatement() returns and the connection that this statement's method getConnection() returns:

Connection connection = datasource.getConnection(); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery(); ... (use the resultSet) resultSet.getStatement().getConnection().close();

Therefore it would be great if you could add a ResultSetDelegator to PGPooledConnection (in addition to PGPooledConnectionDelegator and PGStatementDelegator, PGCallableStatementDelegator, PGPreparedStatementDelegator) and the ResultSetDelegator returns the statement delegator on a call to getStatement() or - as I have seen in the Oracle code - the Statements get a member variable "wrapper" and PGResultSet.getStatement() returns the "wrapper" if it is not null (if it is null the Statement is returned).

BeateSchatzmann avatar Oct 26 '21 13:10 BeateSchatzmann

Love it... see https://github.com/pgjdbc/pgjdbc/issues/2316

davecramer avatar Oct 26 '21 14:10 davecramer