当我运行此代码以连接到ms access db时,出现以下错误:“找不到数据源名称,并且未指定默认驱动程序”

public static Connection getConnection() {
    try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        String database = "jdbc:odbc:Driver={Microsoft Access Driver    (*.mdb,*.accdb)};DBQ=D:/FontsDB.accdb;";
        conn = DriverManager.getConnection(database);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return conn;
}




我使用Netbean7.4,JDK1.7,MS office2013,Win7_64位,
我将odbc属性从%windir%\system32\odbcad32.exe更改为%windir%\SysWOW64\odbcad32.exe,并且我也收到此错误。

最佳答案

驱动程序规格



Driver={Microsoft Access Driver    (*.mdb,*.accdb)}


无效。您需要使用

Driver={Microsoft Access Driver (*.mdb, *.accdb)}


间距很重要。

关于java - java.sql.SQLException:[Microsoft] [ODBC驱动程序管理器]找不到数据源名称,也未指定默认驱动程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23844217/

10-11 02:29
查看更多