Issue Details (XML | Word | Printable)

Key: DBCP-11
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Alexander Rupsch
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Dbcp

[dbcp] stmt.getConnection() != Connection used to create the statement

Created: 08/Aug/05 08:38 PM   Updated: 25/Mar/08 08:11 AM
Return to search
Component/s: None
Affects Version/s: 1.2
Fix Version/s: 1.3

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works back-pointers.patch 2007-07-18 07:27 PM Dain Sundstrom 21 kB
Environment:
Operating System: other
Platform: All

Bugzilla Id: 36077
Resolution Date: 21/Jul/07 03:48 PM


 Description  « Hide
Hi,

I'm not an expert in implementing connection pools or jdbc itself. But shouldn't
the following code work?

Connection con = pool.getConnection()
PreparedStatement ps = con.prepareStatement()

con.equals(ps.getConnection) // returns false!

Ok, I don't need it to be equal, but the following also does not work:

ps.getConnection().close()
con.isClosed() // is false!!!

That means, if I have a Statment and want to close its connection, I have to
remember the conncetion. Is that the requested behavior? Because of this my pool
is running over.

The java.sql API says that Statment.getConnection() has to be the connection
which created the statement.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #558332 Sat Jul 21 15:48:19 UTC 2007 psteitz Modified PoolingDataSource, PoolingDriver and DelegatingStatement to assure
that all all returned Statements, PreparedStatements, CallableStatements and
ResultSets are wrapped with a delegating object, which already properly handle
the back pointers for Connection and Statement. Also added tests to to assure
that the *same* object used to create the statement or result set is returned
from either getConnection() or getStatement().

JIRA: DBCP-11
Patch provided by Dain Sundstrom
Files Changed
MODIFY /jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java
MODIFY /jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
MODIFY /jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TesterPreparedStatement.java
MODIFY /jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TesterStatement.java
MODIFY /jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/PoolingDriver.java
MODIFY /jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingStatement.java
MODIFY /jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/managed/TestManagedDataSourceInTx.java
MODIFY /jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/PoolingDataSource.java
MODIFY /jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TesterConnection.java
MODIFY /jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java