> -----Original Message----- > From: Milan Tomic [mailto:tomicmi...@yahoo.com] > Sent: Wednesday, November 21, 2012 4:36 AM > To: users@tomcat.apache.org > Subject: DB Connection Pool > > > After 1 month of Tomcat 6.0.18 running, I have 50 opened JDBC > connections, which should be closed, but they aren't. All connections > have first or second stack trace: > > TP-Processor22 > java.net.SocketInputStream.socketRead0(Native Method) > java.net.SocketInputStream.read(SocketInputStream.java:129) > java.io.BufferedInputStream.fill(BufferedInputStream.java:218) > java.io.BufferedInputStream.read1(BufferedInputStream.java:258) > java.io.BufferedInputStream.read(BufferedInputStream.java:317) > org.apache.jk.common.ChannelSocket.read(ChannelSocket.java:620) > org.apache.jk.common.ChannelSocket.receive(ChannelSocket.java:558) > org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java > :685) > org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket > .java:889) > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPoo > l.java:690) > java.lang.Thread.run(Thread.java:662) > > TP-Processor29 > java.lang.Object.wait(Native Method) > java.lang.Object.wait(Object.java:485) > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPoo > l.java:662) > java.lang.Thread.run(Thread.java:662) > > Those are my connection pool settings: > > <Resource name="jdbc/myDS" auth="Container" > type="oracle.jdbc.pool.OracleDataSource" > connectionCacheProperties="{InitialLimit=3, MinLimit=3, > MaxLimit=100, AbandonedConnectionTimeout=900, InactivityTimeout=1800, > PropertyCheckInterval=60, ValidateConnection=true}" > connectionCachingEnabled="true" > user="myuser" password="mypass" > factory="oracle.jdbc.pool.OracleDataSourceFactory" > driverClassName="oracle.jdbc.OracleDriver" > url="jdbc:oracle:thin:@someip:1521:myDB" > /> > > What am I doing wrong? I am closing DB connections from my Java code, > but even if I fail to close, it should be automatically closed after > some period (timeout)? > > Thank you in advance, > Milan What version of the Oracle ojdbc driver are you using? If you are using the 11g drivers, you really want the latest. There is an issue with abandoned connection cleanup that is fixed in the 11.2.03 drivers. I am not sure if the issue exists or is fixed in the 10g drivers. Also be sure you are using the version that matches your java release, ojdbc6 == Java6, ojdbc5 == Java5. Which Oracle pooling mechanism are you using? The 10g version was deprecated in the 11g drivers in favor of a new pooling mechanism. Finally, make sure that you understand the Oracle definition of the terms used for paramaters. For example, a connection isn't considered abandoned unless it was checked out of the pool and not used. Once a query is started, a heartbeat is set and the connection must be closed, i.e. returned to the pool, in order to turn off the heartbeat. If the query fails, or the connection is never closed, the abandoned connection mechanism will not see it as abandoned. In other words, make sure that all your connections are being properly closed after use. You must close the result set, query, and connection to do it properly. Once in the pool, the inactivity timeout will take over and close any physical connections that are not being reused. I'm not absolutely sure what mechanism Oracle uses to supply connections, but I strongly suspect a round-robin queue, which means that you'll need 30 minutes of almost no activity before you see connections start to close physically. If you suspect, as I do, that some connections are not being returned to the pool, the easiest way to determine which statements are not closing is to use the "Search Sessions" feature of Enterprise Manager to find sessions which have not be re-used in a long time. The last SQL statement it lists is most likely the culprit. Jeff
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org