• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Singleton objects for data base connection

 
Ranch Hand
Posts: 30
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some gave an example of creating singleton Connection object is more effcient.

How thus can be done and in what way it will be helpfull for the connection?
 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Singleton ensures that only one object has access to the database at a time, therefore reduces load and eliminates consistency issues between processes.
 
Marshal
Posts: 80747
486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most people now doubt that singletons are actually good at all.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Varadhan Sesharaman wrote:Some gave an example of creating singleton Connection object is more effcient.



Singleton is not more efficient. Using one single Connection object for a long time instead of creating new ones that are short-lived and then created a new for every DB action can be more efficient, in the same way that it's more efficient to make one phone call to your friend and say, "Let's meet at 8:00," than to make 4 phone calls, saying, "Let's", and "meet" and "at" and "8:00."

But Singleton doesn't inherently have anything to do with that, nor does its lack.
 
Varadhan Sesharaman
Ranch Hand
Posts: 30
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic