Loading JDBC Driver Class - ojdbc16.jar

This section describes how to load the Oracle JDBC driver class - ojdbc14.jar.

If you are using newer versions of JDK, it will automatically load the Oracle JDBC driver, as long as the JAR file is included in the classpath. There is no need to call Class.forName("oracle.jdbc.OracleDriver") to load the driver class explicitly.

Here is a tutorial program to show you how JDK loads the Oracle JDBC driver:

/* OracleLoadDriver.java
 * Copyright (c) HerongYang.com. All Rights Reserved.
import java.sql.*;
import java.util.*;
public class OracleLoadDriver {
  public static void main(String [] args) {
    Connection con = null;
    try {

      System.out.println("Before loading OracleDriver:");

// Load the Oracle JDBC driver with forName()
      Class.forName("oracle.jdbc.OracleDriver") ;

      System.out.println("After loading OracleDriver:");

    } catch (Exception e) {
  private static void listDrivers() {
    Enumeration driverList = DriverManager.getDrivers();
    while (driverList.hasMoreElements()) {
      Driver driverClass = (Driver) driverList.nextElement();
      System.out.println("   "+driverClass.getClass().getName());

The compilation and execution of the above program were recorded below. Notice the exception error I got without ojdbc11.jar in the classpath:

herong> javac OracleLoadDriver.java

herong> java OracleLoadDriver

Before loading OracleDriver:
java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver

herong> java -cp .;ojdbc11.jar OracleLoadDriver

Before loading OracleDriver:
After loading OracleDriver:

Depending what versions of JDK and Oracle server you are using, you may need use different versions of Oracle JDBC driver JAR file in the class path option, "-cp ...".

Table of Contents

 About This Book

 JDBC (Java Database Connectivity) Introduction

 JDK (Java SE) Installation

 Installing and Running Java DB - Derby

 Derby (Java DB) JDBC Driver

 Derby (Java DB) JDBC DataSource Objects

 Java DB (Derby) - DML Statements

 Java DB (Derby) - ResultSet Objects of Queries

 Java DB (Derby) - PreparedStatement

 MySQL Installation on Windows

 MySQL JDBC Driver (MySQL Connector/J)

 MySQL - PreparedStatement

 MySQL - Reference Implementation of JdbcRowSet

 MySQL - JBDC CallableStatement

 MySQL CLOB (Character Large Object) - TEXT

 MySQL BLOB (Binary Large Object) - BLOB

 Oracle Express Edition Installation on Windows

Oracle JDBC Drivers

 Oracle JDBC Drivers Overview

 JDBC Thin Client-Side Driver Installation

Loading JDBC Driver Class - ojdbc16.jar

 JDBC Driver Connection URL

 Creating Connections with DataSource Class

 DataSource Error - makeURL() Failed

 Getting Driver and Server Information

 "CREATE TABLE" - Creating New Tables

 "INSERT INTO" - Inserting New Data Rows

 Oracle - Reference Implementation of JdbcRowSet

 Oracle - PreparedStatement

 Oracle - JBDC CallableStatement

 Oracle CLOB (Character Large Object) - TEXT

 Oracle BLOB (Binary Large Object) - BLOB

 Microsoft SQL Server Express Edition

 Microsoft JDBC Driver for SQL Server

 Microsoft JDBC Driver - Query Statements and Result Sets

 Microsoft JDBC Driver - DatabaseMetaData Object

 Microsoft JDBC Driver - DDL Statements

 Microsoft JDBC Driver - DML Statements

 SQL Server - PreparedStatement

 SQL Server CLOB (Character Large Object) - TEXT

 SQL Server BLOB (Binary Large Object) - BLOB

 JDBC-ODBC Bridge Driver - sun.jdbc.odbc.JdbcOdbcDriver

 JDBC-ODBC Bridge Driver - Flat Text Files

 JDBC-ODBC Bridge Driver - MS Access

 JDBC-ODBC Bridge Driver - MS SQL Server

 Summary of JDBC Drivers and Database Servers

 Using Connection Pool with JDBC

 Archived Tutorials


 Full Version in PDF/EPUB