Originally posted by Chetan Parekh:
Yeah closing in finally block only.
But suppose if I have 10 open connetions, and I close a connection using above mentioned code, then I will have 10-1 = 9 open connections, right?
No. If you are getting connections from a connection pool set up in weblogic using that datasource, when you close the connection it is returned to the pool. It would then be available for the next request that asks for a connection.
You can monitor connections in the console, see
Monitoring Connections in a JDBC Connection Pool.
If a new connection is opened for each new user or request, you have probabaly missed a place where the connection isn't getting closed.