Dear all,
Spring opens a connection for my statement and closes it later, yk correctly shows it. BUT it also shows a 2nd connection and tells that it is even open.
for further discussion and source code of test cases see:
http://forum.springsource.org/showthrea ... g-only-one
i could also provide a snapshot if needed. (could not find how to upload files here)
thanks
Michael
Spring opens 1 DB connection but yk shows 2
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: Spring opens 1 DB connection but yk shows 2
Hello Michael
Could you please provide snapshot demonstrating the problem.
ftp://upload.yourkit.com/pub/
user ftp
empty password
If you believe that the connection actually closes, but the profiler does not show it as closed, perhaps the connection is not closed via public method close() of Connection interface, thus the event cannot be caught by the built-in probe.
Best regards,
Anton
Could you please provide snapshot demonstrating the problem.
ftp://upload.yourkit.com/pub/
user ftp
empty password
If you believe that the connection actually closes, but the profiler does not show it as closed, perhaps the connection is not closed via public method close() of Connection interface, thus the event cannot be caught by the built-in probe.
Best regards,
Anton
-
- Posts: 3
- Joined: Fri Oct 14, 2011 11:48 am
Re: Spring opens 1 DB connection but yk shows 2
Hi Anton.
Thank for the reply.
see (and try) my simple testcase.
thanks
Michael
Thank for the reply.
As said, my connection is shown correctly. but a 2nd connection is shown, additionally as kept open.If you believe that the connection actually closes, but the profiler does not show it as closed, perhaps the connection is not closed via public method close() of Connection interface, thus the event cannot be caught by the built-in probe.
see (and try) my simple testcase.
uploaded: tomcat-14-10-2011.snapshotCould you please provide snapshot demonstrating the problem.
thanks
Michael
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: Spring opens 1 DB connection but yk shows 2
Thank you for the snapshot.
There are many database connections created in the following stack:
Are you familiar with how/where spring closes that connection, obtained via java.sql.DriverManager.getConnection(String, Properties) ?
There are many database connections created in the following stack:
It seems that Connection.close() method is never called for them, otherwise it would have been caught by the built-in probe.java.sql.DriverManager.getConnection(String, Properties)
org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(String, Properties)
org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(Properties)
org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(String, String)
org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection()
org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSource)
org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSource)
org.springframework.jdbc.core.JdbcTemplate.execute(PreparedStatementCreator, PreparedStatementCallback)
org.springframework.jdbc.core.JdbcTemplate.query(PreparedStatementCreator, PreparedStatementSetter, ResultSetExtractor)
org.springframework.jdbc.core.JdbcTemplate.query(String, PreparedStatementSetter, ResultSetExtractor)
org.springframework.jdbc.core.JdbcTemplate.query(String, Object[], ResultSetExtractor)
org.springframework.jdbc.core.JdbcTemplate.query(String, Object[], RowMapper)
....
Are you familiar with how/where spring closes that connection, obtained via java.sql.DriverManager.getConnection(String, Properties) ?
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: Spring opens 1 DB connection but yk shows 2
P.S.
You use Spring version 2.5.6, right?
If so, please try the latest version 3.0. Perhaps it does not have this problem.
You use Spring version 2.5.6, right?
If so, please try the latest version 3.0. Perhaps it does not have this problem.
-
- Posts: 3
- Joined: Fri Oct 14, 2011 11:48 am
Re: Spring opens 1 DB connection but yk shows 2
i did step-by-step debug the whole spring code and i can ensure you that spring does really and correctly open and close only one connection.
yourkit10 also shows correctly this connection, but also shows one additional open connection, that does not execute any statement nor even tries to connect to db.
this is definitively no spring issue.
yourkit10 also shows correctly this connection, but also shows one additional open connection, that does not execute any statement nor even tries to connect to db.
this is definitively no spring issue.
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: Spring opens 1 DB connection but yk shows 2
Hi,
The probes are very simple: they instrument methods which create the connection and the connection's close() method.
The unclosed connection has been recorded as created in
The object returned from that method is of a class which implements Connection interface. The method "void close()" has never been called for that instance, otherwise the connection would have been shown as closed.
OK, if you say that close() method has been called (at which stack?), the probe might have missed it if:
- the particular Connection class's close() method has not been instrumented for some reason. What is the exact actual class of that connection instance? Can you send its class file?
- the connection was closed via different method instead of the public interface method e.g. directly calling some implementation-specific closeImpl() or whatever.
The probes are very simple: they instrument methods which create the connection and the connection's close() method.
The unclosed connection has been recorded as created in
Code: Select all
java.sql.DriverManager.getConnection(String, Properties)
org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(String, Properties)
OK, if you say that close() method has been called (at which stack?), the probe might have missed it if:
- the particular Connection class's close() method has not been instrumented for some reason. What is the exact actual class of that connection instance? Can you send its class file?
- the connection was closed via different method instead of the public interface method e.g. directly calling some implementation-specific closeImpl() or whatever.