import java.sql.Connection;
import java.sql.DriverManager;
public class DBConnAccess {
public static void main(String[] args) {
String mdbPath = "C:/test.mdb";//数据库路径
try {
String driverClassName = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
Class.forName(driverClassName);
Connection connection = DriverManager.getConnection(url + mdbPath);
System.out.println(connection);
connection.close();
} catch (Exception e) {
System.out.println("连接数据库出错");
e.printStackTrace()
}
}
}