This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes Multiple newInstance() for mySql driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Multiple newInstance() for mySql driver" Watch "Multiple newInstance() for mySql driver" New topic

Multiple newInstance() for mySql driver

Wong Kok Choy

Joined: Feb 05, 2003
Posts: 11
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
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

Joined: Mar 06, 2001
Posts: 13459

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!
Wong Kok Choy

Joined: Feb 05, 2003
Posts: 11
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..
wood burning stoves
subject: Multiple newInstance() for mySql driver