MysqlConnectionPoolDataSource leaving dangling connections
Posted by: Sudhir Movva
Date: April 05, 2005 01:23PM

Hi,
I am using MySQL database for a standalone Java application.

Server version 4.0.15a-log
Protocol version 10
Connection Localhost via UNIX socket

The jdbc driver version is mysql-connector-java-3.0.9-stable-bin.jar

I am trying to use the MysqlConnectionPoolDataSource for connection pooling. Intially i was trying to set the Max-Connections properties via the MysqlConnectionPoolDataSource object instance but found no methods to do so. I am passing few parameters via the connection URL String.
String connUrl = "jdbc:mysql://myHost:3306/dbName?max-connections=10&min-connections=2&inactivity-timeout=30"

MysqlConnectionPoolDataSource cpds = new MysqlConnectionPoolDataSource();
cpds.setUser("userName");
cpds.setPassword("password");
cpds.setURL(connUrl);

I create connections...


for(int i = 0; i<30; i++) {

Connection conn = null;
try {
conn= cpds.getPooledConnection().getConnection();
.....

} catch(....) {
} finally {
conn.close();
conn = null;
if(conn !=null) {
log(...);
}
.....
}
}

Now, after closing the connections, i use mysqladmin proc stat to look at the number of connections to the server, i see 30 connection with status as sleep.
This should not be the case 'coz, whenever a connection is closed the pooled connection gets notification and must clear the resource of the physical connection created earlier.
None of the connections are being closed and more over, even after specifying the max connections, in the URL, more connections are opened.
Even after I close the application, the connections with status sleep are associated with the server.

Can any one give me any pointers as to why this is happening? or can point my mistake?
Thanks,
-Sudhir.

Options: ReplyQuote


Subject
Written By
Posted
MysqlConnectionPoolDataSource leaving dangling connections
April 05, 2005 01:23PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.