Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

refreshing a connection

 
sinasi susam
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am tring to refresh a Connection without closing it phsically from db.
We are using a simple connection pool(hand-made ,and not mine )
How can i do that with out creating a new connection?

I googled for it in the net and in this site ;

http://www.lc.leidenuniv.nl/awcourse/oracle/java.920/a96654/connpoca.htm#1057365

They say ;

"Closing a connection instance that was obtained from a pooled connection does not close the physical database connection. It does, however, free the resources of the connection instance, clear the state, close statement objects created from the connection instance, and restore the defaults for the next connection instance that will be created."

When i saw that i felt so happy then.

But at the next paragraph says;

"To actually close the physical connection, you must invoke the close() method of the pooled connection..."


I am confused.

How can i refresh a connection resources without reopening a new Connection to db?

Thank you.
[ June 01, 2006: Message edited by: sinasi susam ]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off :
We are using a simple connection pool(hand-made
All bets are off anything you read about other pools. You have to know how your pool behaves. If you are using any of the classic pools such as JNDI DataSource pooling, when you ask for a connection, you actually get a wrapped Connection. It's the Wrapper that returns the internal Connection to the pool on close() now if close() is called on the wrapped connection, it does physically close it.

If by refreshing the connection, you mean cause it to release any DB resources that may not have been cleaned up due to sloppy coding, there isn't any way. You must physically close the connection and create a new one. If you refactor your pool you can have it periodically close connections in the background and add new (Fresh) connections to the pool.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic