• Post Reply Bookmark Topic Watch Topic
  • New Topic

DriverManager.registerDriver or class.forName

 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
which one is preferable?

DiverManager.RegisterDriver("class");//compile time
class.forName("class");//loads the calss at Runtime



what to do?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API:

public static void registerDriver(Driver driver) throws SQLException

Registers the given driver with the DriverManager. A newly-loaded driver class should call the method registerDriver to make itself known to the DriverManager.

Therefore the DRiver should call registerDriver when it loads (via Class.forName()) therefore you should not call it yourself.
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!