JDBC drivers are available for most database platforms, from a number of vendors and in a number of different flavors.
There are four driver categories:
Type 1- JDBC-ODBC Bridge Driver
Type 1 drivers use a bridge technology to connect a Java client to an ODBC database service. Sun’s JDBC-ODBC bridge is the most common Type 1 driver. These drivers are implemented using native code.
Type 2- Native-API Partly-Java Driver
Type 2 drivers wrap a thin layer of Java around database-specific native code libraries. For Oracle databases, the native code libraries might be based on the OCI (Oracle Call Interface) libraries, which were originally designed for C/C++ programmers. Because Type 2 drivers are implemented using native code, in some cases they have better performance than their all-Java counterparts. They add an element of risk, however, because a defect in a driver’s native code section can crash the entire server.
Type 3- Net-Protocol All-Java Driver
Type 3 drivers communicate via a generic network protocol to a piece of custom middleware. The middleware component might use any type of driver to provide the actual database access. WebLogic’s Tengah product line is an example. These drivers are all Java, which makes them useful for applet deployment and safe for servlet deployment.
Type 4- Native-Protocol All-Java Driver
Type 4 drivers are the most direct of the lot. Written entirely in Java, Type 4 drivers understand database-specific networking protocols and can access the database directly without any additional software.
The first step in using a JDBC driver to get a database connection involves loading the specific driver class into the application’s JVM. This makes the driver available later, when we need it for opening the connection. An easy way to load the driver class is to use the Class.forName() method:
When the driver is loaded into memory, it registers itself with the java.sql.DriverManager class as an available database driver.
The next step is to ask the DriverManager class to open a connection to a given database, where the database is specified by a specially formatted URL. The method used to open the connection is DriverManager.getConnection() . It returns a class that implements the java.sql.Connection interface:
Connection con =
DriverManager.getConnection("jdbc:odbc:somedb", "user", "passwd");