Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC connection pool

 
Shubhashis Dasgupta
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a question on JDBC connection pools. I have created a connection pool in WebLogic Server and using it from my application. As we know, in case of hand-coded connection pools we release the connection to the pool, once it is used. How do we release a connection in case of server specific connection pool. I am getting the connection object from a datasource related to the connection pool that I have created in WLS. I do not know how to release it.
Shubhashis
 
subramaniam vaidyanathan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I work with weblogic server. Here is how I get a connection:
<code>
DataSource ds = (DataSource) ctx.lookup (dsJNDIName);
conn = ds.getConnection();
</code>
and when I am done with it I just close the connection. The welogic server actually releases it.
<code>conn.close();</code>
Basically leave it to the app server to manage the pool.
 
tim lok
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use Oracle, you can close the resultset as well.
resultSet.getStatement().close();
In doing so, you should be able to prevent any unclosed cursor.
Originally posted by Shubhashis Dasgupta:
Hi all,
I have a question on JDBC connection pools. I have created a connection pool in WebLogic Server and using it from my application. As we know, in case of hand-coded connection pools we release the connection to the pool, once it is used. How do we release a connection in case of server specific connection pool. I am getting the connection object from a datasource related to the connection pool that I have created in WLS. I do not know how to release it.
Shubhashis

 
Shubhashis Dasgupta
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thax tim, subramaniam.
Actually I was not very sure that closing a connection really leads to releasing it to the pool by app. server itself.
 
Tim Chen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the weblogic documentation proof of what happens when you close a connection.
http://e-docs.bea.com/wls/docs60////jdbc/performance.html#1023983
it basically says:
"When a client closes a connection from a connection pool, the connection is returned to the pool and becomes available for other clients; the connection itself is not closed"
 
Vishakha Ahuja
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to know in what ways is a single connection different from a connection pool ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic