Loading Derby JDBC Driver Classes

This section describes how to load the Derby JDBC driver classes.

Derby JDBC driver has two driver classes for Java DB (Derby) running in two different modes:

1. Embedded Driver Class, org.apache.derby.jdbc.EmbeddedDriver - Used to create connections to Java DB (Derby) running in embedded mode. The JAR file and the connection URL format for the embedded driver class are listed below:

Class Name: org.apache.derby.jdbc.EmbeddedDriver
JAR File: C:\Program Files\Java\jdk1.8.0_45\db\lib\derby.jar
Connection URL: jdbc:derby:<database>

2. Client Driver Class, org.apache.derby.jdbc.ClientDriver - Used to create connections to Java DB (Derby) running in Network Server mode. The JAR file and the connection URL format for the client driver class are listed below:

Class Name: org.apache.derby.jdbc.ClientDriver
JAR File: C:\Program Files\Java\jdk1.8.0_45\db\lib\derbyclient.jar
Connection URL: jdbc:derby://<host>:<port>/<database>

Running under Java SE 8, you have 5 options to load Derby JDBC driver:

Of course, I like to try the "Do nothing" option. Here is my testing Java program:

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

// Find the driver for a given URL
      Driver driverClass = (Driver) DriverManager.getDriver(
      System.out.println("\nDriver for jdbc:derby://somehost/somedb");
      System.out.println("   "+driverClass.getClass().getName());
    } catch (Exception e) {
      System.err.println("Exception: "+e.getMessage());
  private static void listDrivers() {
    Enumeration driverList = DriverManager.getDrivers();
    System.out.println("\nList of drivers:");
    while (driverList.hasMoreElements()) {
      Driver driverClass = (Driver) driverList.nextElement();
      System.out.println("   "+driverClass.getClass().getName());

The output below confirms that the DriverManager class is able to load any JDBC driver classes as long as their JAR files are included in the classpath.

C:\herong>\progra~1\java\jdk1.8.0_45\bin\javac AutoLoadJdbcDriver.java

   -cp .;\progra~1\java\jdk1.8.0_45\db\lib\derbyclient.jar 

List of drivers:

Driver for jdbc:derby://somehost/somedb

List of drivers:

Last update: 2015.

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) Driver Features

Loading Derby JDBC Driver Classes

 Creating Connections to Java DB (Derby) Network Server

 Java DB (Derby) Network Server and JDBC Driver Info

 Java DB (Derby) - Creating New Tables

 Java DB (Derby) - Inserting Data Rows to Existing Tables

 Java DB (Derby) - Running SELECT Queries

 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 - Reference Implementation of JdbcRowSet

 Oracle - PreparedStatement

 Oracle - JBDC CallableStatement

 Oracle CLOB (Character Large Object) - TEXT

 Oracle BLOB (Binary Large Object) - BLOB

 Microsoft SQL Server 2005 Express Edition

 Microsoft JDBC Driver for SQL Server - sqljdbc42.jar

 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

 Additional Tutorial Notes to Be Added

 Outdated Tutorials


 PDF Printing Version