JDBC Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 2.11

Java DB (Derby) Network Server and JDBC Driver Info

This section describes how to get some basic info about Java DB (Derby) and JDBC driver through the JDBC DatabaseMetaData object.

If you want to know the Java DB database name and version, or the JDBC driver name and version, you can get them through the DatabaseMetaData object as shown in the following sample program:

/**
 * DerbyDatabaseInfo.java
 * Copyright (c) 2007 by Dr. Herong Yang. All rights reserved.
 */
import java.sql.*;
public class DerbyDatabaseInfo {
  public static void main(String [] args) {
    Connection con = null;
    try {
      con = DriverManager.getConnection(
        "jdbc:derby://localhost/TestDB");

// Database and driver info
      DatabaseMetaData meta = con.getMetaData();
      System.out.println("Server name: " 
        + meta.getDatabaseProductName());
      System.out.println("Server version: "
        + meta.getDatabaseProductVersion());
      System.out.println("Driver name: "
        + meta.getDriverName());
      System.out.println("Driver version: "
        + meta.getDriverVersion());
      System.out.println("JDBC major version: "
        + meta.getJDBCMajorVersion());
      System.out.println("JDBC minor version: "
        + meta.getJDBCMinorVersion());

      con.close();
    } catch (Exception e) {
      System.err.println("Exception: "+e.getMessage());
    }
  }
}

Here is the output of my test program:

C:\>javac DerbyDatabaseInfo.java

C:\>java -cp .;\local\javadb\lib\derbyclient.jar DerbyDatabaseInfo
Server name: Apache Derby
Server version: 10.2.2.0 - (485682)
Driver name: Apache Derby Network Client JDBC Driver
Driver version: 10.2.2.0 - (485682)
JDBC major version: 4
JDBC minor version: 0

Note that Derby JDBC driver supports JDBC 4.0

Sections in This Chapter

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

Dr. Herong Yang, updated in 2007
Java DB (Derby) Network Server and JDBC Driver Info