【问题标题】:ODBC Driver Manager not found .. Connect MSAccess with Java?找不到 ODBC 驱动程序管理器 .. 用 Ja​​va 连接 MSAccess?
【发布时间】:2014-07-17 22:02:49
【问题描述】:

当我运行程序时出现这个问题

来自Control Panel > Administrative Tools > ODBC Data Source (64-bit) User DSN not contain MSAccess

无法添加 Access 驱动程序..

请问如何解决这个问题,谢谢..

这是我的代码。

public class Main 
{
    private static final String MyDataBase = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBO=C:\\Users\\samer\\workspace\\DS2\\DB\\DS2.mdb;";      
    private static Connection conn = null;
    private static Statement stat = null ;

    public Main() 
    {
        try 
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            conn = DriverManager.getConnection(MyDataBase);
            stat = conn.createStatement();
            String sql = "insert into Employee values (1001,'10011001')";
            stat.execute(sql);    
            JOptionPane.showMessageDialog(null , "correct insert");
        } 
        catch (SQLException e1) 
        {
            e1.printStackTrace();
            JOptionPane.showMessageDialog(null , "Sorry1 ,  Try again !!");
        } catch (ClassNotFoundException e2) 
        {
            e2.printStackTrace();
            JOptionPane.showMessageDialog(null , "Sorry2 ,  Try again !!");
        }
    }

    public static void main(String[] args) 
    {
        new Main();
    }
}

【问题讨论】:

  • 您需要确保您的位深度在所有点上都是相同的,x64 Java、x64 Access 驱动程序、x64 位 Access(或 32 但全面)。玩Access已经有一段时间了,但你应该确保已经安装了Access(我认为你可以安装驱动程序,但已经有一段时间了)

标签: java database odbc


【解决方案1】:

我相信驱动程序正在消失(它不在 Java 8 中)。

我一直在 Java 中使用称为 UCanAccess 的 JDBC 解决方案,它对我来说运行良好。

http://ucanaccess.sourceforge.net/site.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-14
    • 2019-07-15
    • 2021-07-22
    • 2014-07-23
    • 2013-11-11
    • 2020-10-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多