JDBC for SQL Server - Herong's Tutorial Examples - v3.14, by Herong Yang
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) HerongYang.com. 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:
herong> progra~1\java\jdk1.7.0_45\bin\javac OdbcAccessDatabaseInfo.java herong> progra~1\java\jdk1.7.0_45\bin\java OdbcAccessDatabaseInfo 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.
Table of Contents
JDBC (Java Database Connectivity) Introduction
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
Using Connection Pool with JDBC
JDBC-ODBC Bridge Driver - sun.jdbc.odbc.JdbcOdbcDriver
JDBC-ODBC Bridge Driver - Flat Text Files
►JDBC-ODBC Bridge Driver - MS Access
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