| Author |
I need advice from a guru
|
Hanna Habashy
Ranch Hand
Joined: Aug 20, 2003
Posts: 532
|
|
hi: I am new in using JDBC, but I think I have good understanding of how to create an destroy a connection using a connection pool and datasource. Here is my situation: The Database admin accusing me of not writing good code. He says that my code leaves database connections open. I close all my connections proporly in a finally clause. I ran a simulator accessing the database and excuting a SQL statement. I ran the simulatore on Tomcat accessing SQL server 2k. The simulator run in 5 windows, 5 users, with 10000 connections per user. Total of 50000 times of opening, excuting a query, and then closing a connection. After the simulation stoped, and after the connection idle time out past, he could see from his side that there are about 3 or 4 connections open. The minimum number of connection on the server is 2. He is telling me that there are 1 or 2 connections are not closed. I know there is nothing wrong with the code. Is it normal that some connection will still open? How can I answer his demands for closing all the connections? I really appreciate any help.
|
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8260
|
|
A connection pool keeps several connections open to avoid the overhead of creating and destroying them. when you "close" a connection from a connection pool, it isn't really closed, it is placed back in the pool for use at a later time. Depending on how your pool is implemented, it may create additional connections in order to handle a large load, and it may hold onto those connections as well. I think the connections the DBA is seeing are the ones that the connection pool is maintaining. If you really were creating connections and leaving them open (a "connection leak"), your DBA would have several thousand connections to look at. That is, if the database didn't crash first. [ March 02, 2004: Message edited by: Joe Ess ]
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
 |
|
|
subject: I need advice from a guru
|
|
|