wood burning stoves 2.0*
The moose likes JDBC and the fly likes Database helper class and closing question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Database helper class and closing question" Watch "Database helper class and closing question" New topic
Author

Database helper class and closing question

Joseph Smithern
Ranch Hand

Joined: Feb 11, 2006
Posts: 89
I have a JDBC working with Oracle 9i where database is inserted/updated maybe 10 times at most during a week with very little usage in my Tomcat 4.1.3 Container.

The Database classes I have used for the past year are working great but I wonder if I should be closing anything in my database helper class with Prepared statements:




When I experiment and put a close statement in the DbInsert class method then my database insert wont work because it would be closed when it is called in the DbWork class?


Please advise.
[ November 08, 2007: Message edited by: Joseph Smithern ]
Les Hayden
Greenhorn

Joined: Jun 19, 2002
Posts: 28
you say
put a close statement in the DbInsert class method


but in your code you use connection.close();. If you indeed want to close the statement then you should use


Les Hayden
Joseph Smithern
Ranch Hand

Joined: Feb 11, 2006
Posts: 89
Thanks, I was also wondering if the way I am doing it is not recommended because I am keeping the Connection and PreparedStatement as an instance variable.

Is this better or more efficient way where I combine it into one class??


[ November 12, 2007: Message edited by: Joseph Smithern ]
 
Don't get me started about those stupid light bulbs.
 
subject: Database helper class and closing question
 
Similar Threads
Connection attempt
insert command is not working.
Database Connectivity
JDBC-ODBC
Best way to connect?