Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to return connection to pool

do we need to call any method on dbcp.BasicDataSource or jndi datasource(i'm using jboss) to return the connection after done with it?

like image 206
user920420 Avatar asked Aug 30 '11 20:08

user920420


People also ask

What is connection pool timeout?

Connection timeoutThis value indicates the number of seconds that a connection request waits when there are no connections available in the free pool and no new connections can be created. This usually occurs because the maximum value of connections in the particular connection pool has been reached.

How do you release a connection pool?

You can disable Pooling by adding 'Pooling=false' to the connection string. In such case, a connection will be deleted from memory and free the session.

How do I know if connection pooling is working?

A simple way to check pool members are re-used: If your JDBC vendor is using the standard toString from Object you should see the same values printed when you print the connection: If this changes each pool get call, then the connection is not the same as before.

Do we need to close connection in connection pool?

Yes, certainly you need to close the pooled connection as well. It's actually a wrapper around the actual connection. It wil under the covers release the actual connection back to the pool.


1 Answers

Nope, just call Connection.close(). If this connection was obtained from a pooled data source, then it won't actually be closed, it'll just be returned to the pool.

like image 141
skaffman Avatar answered Oct 19 '22 11:10

skaffman