• 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

role of drivers

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is drivers role in jdbc... what happens when we give class.forName(.....); (ie.) behind the scene.. who is the driver manager... explain..

thanks....
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the class.forName method you get an instance of the Driver class used to handle the communication with the DB for example if you are using mySQL the com.mysql.jdbc.Driver class in the jdbc jar file is used, each Driver class should implement a bunch of interfaces specified by SUN some are mandatory while others are optional for example each Driver class should implement the following interfaces:

java.sql.Driver
java.sql.DatabaseMetaData
java.sql.ResultSetMetaData


in addition each driver should have a static initializer that should do two things

1) Creates an instance of itself
2) Registers the newly-created instance by calling the method DriverManager.registerDriver

if you need more information ... click here



(peace)
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you seen our JDBC FAQs? There is lots of useful information there.
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vinoth,

On the First note, dont post same question again and again. Please be patient till people reply.

Coming to your question. JDBC technology which is packaged along with JDK contains mostly interfaces ( Connection, Statement, Resultset) . This is done so ( infact to be done so) just to enable the independent database vendors to provide their own implementations.

what happens when we give class.forName(.....); (ie.) behind the scene.. who is the driver manager...



This is where it all starts. DriverManager is one of the classes( note : its a class) implemented in JDBC to load and understand the driver.Class.forName actually
1) Loads the class specified as part of "String parameter).
2) Registers with the Driver Manager. ( note : only driver class gets registered not ordinary classes , meaning the Database vendor Driver class has to be comply certain Driver manager rules.)

And, so when DriverManager.getConneciton is called , DriverManager checks for the loaded drivers and choose the one which is suited for the application. and there you go , get the connection , and store it Interface object Connection. And when you invoke Connection objects, its actually the runtime DB vendor specific implementation is claaed (remember polymorphism) .

is that clear

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
vinoth ar, please be sure to take the time to compose descriptive subjects for your posts; read this for more information.

Using a title of "jdbc" in a forum completely dedicated to questions on JDBC isn't very helpful. This is the second topic you've started with this title. How are we to tell them apart? What if everyone named every topic in this forum "jdbc"?

Please go back and change your post to add a more meaningful subject by clicking the
reply
    Bookmark Topic Watch Topic
  • New Topic