Alexander Rupsch wrote: > Hi, > > I'm not an expert in implementing connection pools or jdbc itself. But > shouldn't the following code work? > > Connection con = pool.getConnection() > PreparedStatement ps = con.prepareStatement() > > con.equals(ps.getConnection) // returns false! > > Ok, I don't need it to be equal, but the following also does not work: > > ps.getConnection().close() > con.isClosed() // is false!!! > > That means, if I have a Statment and want to close its connection, I > have to remember the conncetion by myself. Is that the requested > behavior? Because of this my pool was running over. > > The java.sql API says that Statment.getConnection() has to be the > connection which created the statement. >
I cant tell what pool technology you are using and in what specific environment. But in general, pools do the handling for you. They implement connection reuse: that is, the connnection is only closed virtually (e.g. freed for reuse) and not closed physically to improve performance. In consequence pools need to keep track if a connection can be reused or not (e.g. pool grows on subsequent getConnection requests). This is done by keeping track whether all statements and resultset have been closed so far. Otherwise, the connection will not be reused and your pool will grow and grow ... So check if you forgot to close a statement or a resultset somewhere (put the close() calls into a finally block to get sure that they are invoked properly). Hope it helps. -- Alexander Sack +49 (40) 692 13 - 179 e-mail: [EMAIL PROTECTED] Contelligent ... CMS for j2ee & devels - http://www.contelligent.com C:1 Financial Services GmbH - Dorotheenstr. 64 - 22301 Hamburg --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
