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.