Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResultSetDelegator for PGStatementDelegator #566

Open
BeateSchatzmann opened this issue Oct 26, 2021 · 1 comment
Open

ResultSetDelegator for PGStatementDelegator #566

BeateSchatzmann opened this issue Oct 26, 2021 · 1 comment

Comments

@BeateSchatzmann
Copy link

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).

@davecramer
Copy link

Love it... see pgjdbc/pgjdbc#2316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants