• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database helper class and closing question

 
Joseph Smithern
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Joseph Smithern
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic