• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

load and register driver

 
priyanaka jaiswal
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

why we load and Register the driver in Jdbc?
 
Philip Grove
Ranch Hand
Posts: 68
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
priyanaka jaiswal wrote:Hi All,

why we load and Register the driver in Jdbc?


I am not sure I understand you correctly, but the JDBC does not know of specific databases so you need to add that information somehow.
 
priyanaka jaiswal
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you philip
 
Ashutosh Limaye
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
priyanaka jaiswal wrote:Hi All,

why we load and Register the driver in Jdbc?


The JDBC driver is the implementation of the JDBC specification. A type four JDBC driver in particular is normally provided to us by the database vendor.
Now in order to get connected to that DB we require to load the driver in the heap. Since the location of only the library classes is known in advance, you have to provide the location for your driver by setting the classpath to point to the driver's jar file and at the same time using fully qualified name in the Class.forName() method.
More over your program might be bringing data from various databases in which case you might require two or more drivers at the same time. To have an ordered access to the drivers JDBC provides us with the DriverManager . Usually every Driver has to register itself with the DriverManager. The registration code could be written inside a static block in the Driver class, hence Class.forName(), a single line does both loading and registration of the driver.(static blocks are executed during load time)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic