Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

Should I close a connection when using DataBase Pool?

Thread view: 
JTL.zheng - 08 Nov 2007 14:09 GMT
database pool means that the conncetion can be used by other user.
so when I finish the job, should I call
conn.close();
after it as the old way?
Sebastian Millies - 08 Nov 2007 14:55 GMT
Am Thu, 08 Nov 2007 06:09:06 -0800 schrieb JTL.zheng:

> database pool means that the conncetion can be used by other user.
> so when I finish the job, should I call
> conn.close();
> after it as the old way?

Yes. However, you should refer to the documentation of
your pool library to be sure. E. g. it could be like this:
PooledConnection conn = Pool.getConnection();
...
conn.close()
where the implementation of PooledConnection#close()
may choose to return the connection to the pool.

-- Sebastian
Wojtek - 08 Nov 2007 15:58 GMT
Sebastian Millies wrote :
> Am Thu, 08 Nov 2007 06:09:06 -0800 schrieb JTL.zheng:
>
[quoted text clipped - 10 lines]
> where the implementation of PooledConnection#close()
> may choose to return the connection to the pool.

As noted above, you should alwasy explicitly close connections (and
result sets, and cursors, and statements, and ...).

Some pool managers (proxool for example) will automatically clean up
connection resources such as statements and result sets.

And proxool will also close connections after a certain number of
seconds.

Signature

Wojtek :-)

JTL.zheng - 11 Nov 2007 01:38 GMT
Thank you very much.
so I should close the connection however it will not be destoried but
be returned to tomcat.
Esmond Pitt - 11 Nov 2007 23:06 GMT
> Thank you very much.
> so I should close the connection however it will not be destoried but
> be returned to tomcat.

Not to Tomcat: returned to the JDBC driver's connection pool.
JTL.zheng - 12 Nov 2007 04:45 GMT
is it not the web container like tomcat or weblogic implement the
database pool but the database driver itself like mysql's java
connector?
Arne Vajhøj - 12 Nov 2007 04:49 GMT
> is it not the web container like tomcat or weblogic implement the
> database pool but the database driver itself like mysql's java
> connector?

Usually it is the container that implements the connection pool.

Arne
JTL.zheng - 14 Nov 2007 03:31 GMT
Thank you very much.
: -)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.