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

JDBC-ODBC - MS Access Database and Driver Info

This section describes how to get some basic info about the Access database and the driver through the JDBC DatabaseMetaData object.

If you want to know the Access 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:

/**
 * OdbcAccessDatabaseInfo.java
 * Copyright (c) 2007 by Dr. Herong Yang. All rights reserved.
 */
import java.sql.*;
public class OdbcAccessDatabaseInfo {
  public static void main(String [] args) {
    Connection con = null;
    try {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      con = DriverManager.getConnection("jdbc:odbc:HY_ACCESS");

// 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());
    }
  }
}

If you run this program you will get:

Server name: ACCESS
Server version: 04.00.0000
Driver name: JDBC-ODBC Bridge (odbcjt32.dll)
Driver version: 2.0001 (04.00.6304)
JDBC major version: 2
JDBC minor version: 0

Note that ODBC driver reported that the version of MS Access used to create this database is 04.00.0000.

Sections in This Chapter

JDBC-ODBC - Creating a MS Access Database File

JDBC-ODBC - Creating DSN for MS Access

JDBC-ODBC - Connecting to MS Access Database Files

JDBC-ODBC - MS Access Database and Driver Info

JDBC-ODBC - Creating New Tables in MS Access Database

JDBC-ODBC - Inserting Data Rows to MS Access Database

JDBC-ODBC - Running Queries on MS Access Database

Creating Connections with DataSource Class

Dr. Herong Yang, updated in 2007
JDBC-ODBC - MS Access Database and Driver Info