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 / July 2006

Tip: Looking for answers? Try searching our database.

DataSource and Connection

Thread view: 
Daniel - 15 Jul 2006 01:38 GMT
Hi all,

I have been using javax.sql.DataSource to get a Connection to the database.
Since it's supposed to get a Connection from the pool, I am wondering once I
am finished with the Connection object, do I need to close it? How do I
return it to the pool?

Doing it the old way with Class.forName and DriverManager, once I got the
Connection and finished it I did indeed close the Connection.

How about with DataSource?

I am using:
1) Tomcat 5 and MySQL
2) Oracle 9i AS and 9i DB

Thanks in advance!
raymondwlees@gmail.com - 15 Jul 2006 06:45 GMT
> Since it's supposed to get a Connection from the pool, I am wondering once I
> am finished with the Connection object, do I need to close it? How do I
> return it to the pool?

For good practice, you still need to do conn.close() in finally block
to return the database connection to the pool. You just don't need to
write Class.forName to load the JDBC driver, and you get connection
from datasource instead of DriverManager.


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.