• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Driver wanted

 
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is for a Cattle Drive assignment, so I can't post a lot of code. I've got a database that I want to access for purposes of displaying a list of videos in table format. (My code works, but it has issues.) Currently I put the code for loading the driver inside the block of code that handles the login. My reasoning for this was that once the login is successful, I want my app to display the list of videos stored in the database, and in order to do that, I have to have access to the database.
Apparently, this is a poor choice. My nitpicker made a reference to a popular website that has thousands of people logging in every few minutes, and I guess loading the driver with each login is bad. I just don't know why.
What is the issue with loading the driver? When should it be done, and for what reasons?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a bit of overhead associated with loading the driver, so in general it should be avoided simply in order not to do something repeatedly that acoomplishes nothing. Having said that, I don't think the overhead of Class.forName is sizeable, because once the class (and driver) is loaded, the next call will determine that it is loaded already, and not do anything else.

Generally the driver initialization should be done during application startup, e.g. in Servlet.init if this is a web app.
reply
    Bookmark Topic Watch Topic
  • New Topic