Bug 48392

Summary: jdbc-pool is not returning the proxied connection in resultSet and statement
Product: Tomcat Modules Reporter: gfernandes <gsfernandes>
Component: jdbc-poolAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: critical CC: fhanik
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: JdbcInterceptor to proxy resultSets and statements
Statement decorator interceptor that proxies the resultSet and statement.
A correction to the createDecorator() method in the interceptor

Description gfernandes 2009-12-15 11:43:20 UTC
The proxy connection returned by the jdbc-pool is not proxying the resultSet and the statement so if the client gets access to the underlying connection through: 

resultSet.getStatement().getConnection()

He is able to close the physical connection due to both instances (resultSet and statement) were not proxied. 
If this happens next time a client gets a connection from the jdbc-pool it will return a proxy with a physical connection closed.
Comment 1 gfernandes 2009-12-15 12:08:01 UTC
jdbc-pool version is: 1.0.7.1
Comment 2 gfernandes 2009-12-16 11:26:26 UTC
Created attachment 24713 [details]
JdbcInterceptor to proxy resultSets and statements

Implemented a JdbcInterceptor to proxy resultSets and statements.
Comment 3 Konstantin Kolinko 2009-12-16 19:10:14 UTC
For reference: link to the discussion thread on users@:
http://markmail.org/thread/lf4l3tjy5eev5kxo
http://marc.info/?t=126089853000004&r=1&w=2
Comment 4 Filip Hanik 2010-02-24 17:44:08 UTC
The patch contains a package name we can't use, and it doesn't have any license header in it.

Can you adjust the package name to 
org.apache.tomcat.jdbc.pool.interceptor

and add the license header (just look at an existing source file)
Comment 5 gfernandes 2010-02-24 18:06:13 UTC
Created attachment 25054 [details]
Statement decorator interceptor that proxies the resultSet and statement.

Corrected the package and added the license header as suggested by Filip.
Comment 6 Filip Hanik 2010-02-24 19:28:36 UTC
Thank you for the patch. It's been committed with a change to org.apache.juli.Log instead of Log4j
Comment 7 Neil Clarke 2011-09-05 08:54:34 UTC
Created attachment 27457 [details]
A correction to the createDecorator() method in the interceptor

There appears to be a typing error in the createDecorator() method of the interceptor, setting the connection to the constructor object:

statementProxy.setConnection(proxy);
statementProxy.setConstructor(constructor);
Comment 8 Filip Hanik 2011-09-12 15:25:29 UTC
Thank you
Fixed in r1169796
Comment 9 KMI 2019-11-13 13:01:43 UTC
Hi,


I'm using ddlutils 1.0 and tomcat jdbc pool 1.0.7.1 and I getting an error
due to a connection is closed and the pool is not aware of that.
Basically the issue is that ddlutils has a resultset iterator and when it
finishes it closes the connection by getting it from the *
resultSet.preparedStatement.connection* and the connection returned is not
the proxy that the pool has created.


So the issue happens when another client retrieves a connection from the
pool because the pool returns a connection that was actually closed.
Why tomcat jdbc pool is not creating proxies for preparedStatements and
resultSets like commons-dbcp?


Is there any other way to address this issue?

Thanks

Antonio - https://kmidata.es/