Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

What is a driver class and why should it be registered?

Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The very first step in connecting a mysql database in java is to register the driver class using the following code.

What is a driver class?
What is the need to register a driver class?
Why don't we register any driver classes in our regular java programs (which don't connect to a database)?

Thanks in advance.
Posts: 23879
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Well, simply, the JDBC driver is the implementation that know how to get to the particular database.

For example, let's say you want to use JoeBob Database (tm). First step, obviously, is to setup the database. Second step, get the JoeBob database implementation driver from Joe Bob corporation. This will most likely be a jar file, that you will need to add to the class path.

And finally, if you are using an old implementation, you will need to add a line of code that will register with the JDBC manager, on how to find the drivers to get to JoeBob database (hence, your question). Also note, with newer versions of Java, there is an option in the jar file that will automatically load the driver, so that line would no longer be needed.

    Bookmark Topic Watch Topic
  • New Topic