Home Tutorial Java Jdbc How To Use Database Driver


Share on Google+Share on Google+
How To Use Database Driver
Posted on: October 20, 2010 at 12:00 AM
In this tutorial you will learn how to use a MySql database driver.

How To Use Database Driver

Database driver is a component (Software component) that enables the user application to interact with database. In JDBC there are four types Database driver

Type 1: JDBC-ODBC Bridge driver
Type 2: Native-API/partly Java driver
Type 3: AllJava/Net-protocol driver
Type 4: All Java/Native-protocol driver

Each database driver have there advantages and disadvantage. Type 4 driver is widely used today.

Driver Manager keeps track of all the database drivers available today and connection between database and driver. It maintains a list of driver classes that has registered them self by calling a method DriverManager.registerDriver.

Every database application have their own database driver. In order to connect to an application to database using type 4 driver you must need to load a database driver of that particular database. Loading a driver means loading appropriate class that makes driver instance and register it with JDBC driver manager. If the the class/driver you are loading not found then it throws a ClassNotFoundException. To load a database driver Class.forName("DriverName") method is used. This method takes string as argument which is fully qualified class name and loaded that class.


try {
    Class.forName("com.mysql.jdbc.Driver"); //MySql Driver
    //Class.forName("oracle.jdbc.driver.OracleDriver"); Oracle driver
    //Class.forName("com.sybase.jdbc.SybDriver"); Sybase driver
    } catch(ClassNotFoundException e) {


Related Tags for How To Use Database Driver:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 20, 2010

Recommend the tutorial

Advertisements Advertisements