public class AccessTest {
private final static String MDB_FILE = "C:\\test\\TestDB.accdb";
public static void main(String[] args) throws Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb,*.accdb)};DBQ=" + MDB_FILE;
Connection conn = DriverManager.getConnection(url);
String sql = "select * from login_user";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
System.out.println(rs.getInt(1));
}
rs.close();
stmt.close();
conn.close();
}
}
private final static String MDB_FILE = "C:\\test\\TestDB.accdb";
public static void main(String[] args) throws Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb,*.accdb)};DBQ=" + MDB_FILE;
Connection conn = DriverManager.getConnection(url);
String sql = "select * from login_user";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
System.out.println(rs.getInt(1));
}
rs.close();
stmt.close();
conn.close();
}
}