下面提供一段java通过JDBC连接Access数据库的例子:
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
System.out.println(e);
}
Connection conn = null;
try {
conn = DriverManager.getConnection(
"jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:/CodeBase/WebApp/UserInfo.mdb",
"", "");
Statement ps = conn.createStatement();
ResultSet rs = ps.executeQuery("select * from user");
} catch (SQLException ex) {
参考文档
Microsoft Access accdb ODBC Driver connection strings
https://www.connectionstrings.com/microsoft-access-accdb-odbc-driver/