• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Data Access Code

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

 
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic