我尝试了以下方法:
private String password = "";
private String dbName = "dataHC.accdb";
private String bd = dbName + ";PWD=" + password;
String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="+bd+";";
private Connection conn = null;
//Connect
public void connect() {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(url);
if (conn != null)
System.out.println("Conexión a base de datos "+dbName+". listo");
}catch(SQLException e){
System.out.println(e);
}catch(ClassNotFoundException e){
System.out.println(e);
}
}
字体:http://www.jc-mouse.net/base-de-datos/consultas-con-parametros-en-access-y-java
我得到这个错误:
[Microsoft] [ODBC Microsoft Access驱动程序]常规错误无法打开注册表项进程0x7f8线程0x1174 DBC的Ace DSN(临时)
特别
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x7f8 Thread 0x1174 DBC 0x8dc8d78 Jet'.
Exception in thread "main" java.lang.NullPointerException
at depuracionDB.consultap(depuracionDB.java:67)
at depuracionDB.main(depuracionDB.java:103)
我正在使用Eclipse IDE Luna和Java版本“ 1.7.0_45”(64位)
汪汪一只猫
www说
莫回无