File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Bad practice with datasource? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Bad practice with datasource?" Watch "Bad practice with datasource?" New topic
Author

Bad practice with datasource?

Gary Seibold
Greenhorn

Joined: Oct 08, 2004
Posts: 7
Is this a bad practice when using datasources? I am thinking of connection pooling and wondering if there is a connection left open.
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
You need to close your connections, too.


James Carman, President<br />Carman Consulting, Inc.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26489
    
  78

Gary,
Also, you should close the statement and connection in a finally block.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Bad practice with datasource?
 
Similar Threads
database connection in servlet
Is it the right way?
Need help on Passing parameters
Transaction EJB session bean
Empty catch statement in JDBC code