File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple newInstance() for mySql driver

 
Wong Kok Choy
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I'm kinda new to database programming in Java. I'm currently working on several JSP pages, and everytime one of these pages load, I issue the command
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
I was just wondering if there's anything wrong with having multiple calls to newInstance()?
Would really appereciate any feedback regarding this issue. Thanks a lot everyone..
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We covered a similar question in this thread and I decided in that case it wasn't a good idea.
Your situation is slightly different, in that I don't believe each call will cause the driver to be registered, all you will be doing is creating an instance that is never used. ie there is a small waste of memory invloved but it shouldn't cause big problems.
In cases like this we always recommend Connection Pools. Then the management of connections and the registration of the drivers is managed from a central location and this problem of yours and several other just... goes away!
Dave
 
Wong Kok Choy
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks david! really appereciate your prompt response. I will look into implenting connection pools. I guess I have a lot of reading to do as this is something new to me..Thanks again..
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic