This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Data Access Code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Data Access Code" Watch "Data Access Code" New topic
Author

Data Access Code

M Jay
Ranch Hand

Joined: Sep 21, 2004
Posts: 66
Hi,

I am writing a Data Access Layer. At first I made this a Singleton class, so that the same DB connection is used everytime, to avoid creating many connections. Then I changed my code to use DataSource and connection pooling with Tomcat, and now I'm not sure how to go about.

I need the DataSource lookup code to run only once, and use this one DataSource to get connections to the DB. Should I keep the class a singleton?

Not sure if that will work as I am thinking to make my Connection object a member variable.

Below is my current DA class, any advice would be much appreciated:



SCJP J2SE 1.4<br />SCBCD J2EE 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data Access Code