无法使用 Windows-64 位连接到 MS Access DB [英] Can't connect to MS Access DB with Windows-64bit

查看:61
本文介绍了无法使用 Windows-64 位连接到 MS Access DB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
Microsoft Access 和 Java JDBC-ODBC 错误

我在创建数据库时遇到了问题.我有一个 64 位版本的 Windows 7,发现错误是 Microsoft Office 是 32 位.我能够使用 c:\Windows\sysWOW64\odbcad32.exe 中的 odbcad32.exe 创建我的 Access 数据库

I had issues with creating my DB to begin with. I have a 64bit version of Windows 7 and found out the error was with Microsoft Office being 32bit. I was able to create my Access database by using the odbcad32.exe found in c:\Windows\sysWOW64\odbcad32.exe

现在在我的 Java 代码中,我只是想建立连接,但又遇到了似乎相关的问题,这让我觉得最多只是没有正确设置数据库.JavaDB 是我在 ODBC:DSA 中创建的数据源的名称,您可以在这里看到:http://i.imgur.com/9n19x.png

Now in my Java code I am simply trying to get connected but am running into issues again that seem to be related, and make me feel like at the most I just didn't set up the database correctly. JavaDB is the name of my data source I created in the ODBC:DSA as you can see here: http://i.imgur.com/9n19x.png

我一直在互联网上搜索,但无法真正找到可靠的明确答案.真的可以使用帮助,在此先感谢!

I've been searching all over the internet but can't really find a solid definite answer. Could really use the help, thanks in advanced!

我清理了我的代码,现在我的错误有所不同.我在 C:\Eclipse\project1\src 的项目文件夹中有我的物理数据库文件 - 我已经像我在 ODBC 中所说的那样进行了设置.

I cleaned up my code and now my error is different. I have my physical database file in my project folder at C:\Eclipse\project1\src - I have set it up as well like I said in the ODBC to be the same.

EDIT 嗯,经过数小时的研究,我最终才弄明白了.问题不是我的代码,而是与 Windows x64BIT 和 Office 中的 32 位驱动程序的兼容性问题.这篇文章帮助我修复了它,现在它可以工作了!http://www.selikoff.net/2011/07/26/connecting-to-ms-access-file-via-jdbc-in-64-bit-java/

EDIT Well, after hours and hours of research I ended up just figuring it out finally. The issues wasn't as much my code, as it was compatibility issues with Windows x64BIT and 32 bit drivers in Office. This article helped me fix it, and now it works! http://www.selikoff.net/2011/07/26/connecting-to-ms-access-file-via-jdbc-in-64-bit-java/

import java.sql.*;

public class DBTester {

public static void main(String[] args) throws SQLException, ClassNotFoundException {

try 
{

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


    String fileName = "C:/Eclipse/school/bin/RegistrationDB.mdb";


    String dB = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="+fileName;
    Connection connection = DriverManager.getConnection(dB,"","");

    System.out.println("connected");

    Statement s = connection.createStatement();
    s.close();
    connection.close();

} catch(Exception ex)
{

    ex.printStackTrace();

}


} // end main

} // end class

推荐答案

经过大量研究并在此处和其他地方看到大量与我的问题相关的未解决问题后,我偶然发现了一篇文章,其中有一个简单的修复方案,这让我很想打我进入我的办公桌.

After much research and seeing tons of unanswered questions related to mine here and other places I stumbled upon an article with a simple fix that made my want to hit my head into my desk.

http://www.selikoff.net/2011/07/26/connecting-to-ms-access-file-via-jdbc-in-64-bit-java/

如果您拥有 64 位 Windows 7 机器和 32 位版本的 Access - 您将会遇到问题.从这篇文章中,我能够卸载我当前的 MS Access - 并重新安装 64 位版本.重新添加了我的数据库源,一切正常.

If you have a 64bit Windows 7 machine and a 32Bit version of Access - you are going to have issues. From this guys article, I was able to uninstall my current MS Access - and -reinstall a 64 bit version. Re-added my DB sources and everything worked.

这篇关于无法使用 Windows-64 位连接到 MS Access DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆