如何在 Windows 2008 上将 64 位 Java ODBC 驱动程序与 Access 数据库一起使用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2381504/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 20:53:39  来源:igfitidea点击:

How do I use 64-bit Java ODBC driver with a Access database on Windows 2008?

javams-access64-bit

提问by djangofan

For years, on 32-bit systems I have never had a problem. Why can't I use 64-bit Java ODBC driver with a Access database on Windows Server 2008? Is the ODBC driver on a 64-bit system written in 32-bit code or something? Here is the error I see, using a 64-bit JDK1.6.018 :

多年来,在 32 位系统上我从来没有遇到过问题。为什么我不能将 64 位 Java ODBC 驱动程序与 Windows Server 2008 上的 Access 数据库一起使用?64 位系统上的 ODBC 驱动程序是用 32 位代码编写的吗?这是我看到的错误,使用 64 位 JDK1.6.018 :

java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
        at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3073)
        at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
        at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
       .....

I suspect that the Access driver is 32-bit because it doesn't show up in the 64-bit ODBC control panel for windows. Only two 64-bit drivers (for SQL Server) are visible in the "Drivers" tab of the ODBC control panel.

我怀疑 Access 驱动程序是 32 位的,因为它没有出现在 Windows 的 64 位 ODBC 控制面板中。在 ODBC 控制面板的“驱动程序”选项卡中只能看到两个 64 位驱动程序(用于 SQL Server)。

So, what can I do? I would rather not have to use SQL Server and the JDBC Type-4 driver (but that would be my last resort).

那么,我能做什么?我宁愿不必使用 SQL Server 和 JDBC Type-4 驱动程序(但这将是我最后的手段)。

采纳答案by Yishai

Microsoft Access in Office 2010 will have a 64 bit version. Earlier versions of Microsoft Office are 32 bit only.

Office 2010 中的 Microsoft Access 将具有 64 位版本。早期版本的 Microsoft Office 仅为 32 位。

Using SQLExpressis both free and easy enough to use, and Access and Java can connect to it, so it seems like a good choice.

使用SQLExpress既免费又好用,而且 Access 和 Java 都可以连接到它,所以它似乎是一个不错的选择。

Since you said that was a last resort, the other option is to run the 32-bit JDK, which should run fine on Server 2008.

既然你说这是最后的手段,另一个选择是运行 32 位 JDK,它应该在 Server 2008 上运行良好。

回答by Ta01

Have you tried launching the 32-bit ODBC manager from Windows 2008 - to see if that helps you diagnose the issue?

您是否尝试过从 Windows 2008 启动 32 位 ODBC 管理器 - 看看这是否有助于您诊断问题?

The 32-bit version of the Odbcad32.exe file is located in the %systemdrive%WindowsSysWoW64 folder

32 位版本的 Odbcad32.exe 文件位于 %systemdrive%WindowsSysWoW64 文件夹中

回答by Oleg Efrem

I had same problem. The cause was that i was using 64 Bit ODBC DSN with a 32 Bit JDK. These should be same architecture (both ODBC DSN and JDK need to be either 64 bits or 32 bits). If you would register ODBC DSN on 32 bits and calling from a 64 bit application (64 bit JVM) you would get an error that DSN source is not found (So for the application to see the ODBC source - the JVM you are running the app should be same architecture as ODBS DSN: both needs to be 64 bits, or both 32 bits). Hope this helps.

我有同样的问题。原因是我使用 64 位 ODBC DSN 和 32 位 JDK。这些应该是相同的架构(ODBC DSN 和 JDK 都需要是 64 位或 32 位)。如果您将在 32 位上注册 ODBC DSN 并从 64 位应用程序(64 位 JVM)调用,您将收到一个错误,指出 DSN 源未找到(因此,应用程序要查看 ODBC 源 - 您正在运行应用程序的 JVM)应该是与 ODBS DSN 相同的架构:两者都需要是 64 位,或者都是 32 位)。希望这可以帮助。

回答by Monty Saapra

If you use Microsoft Office 2010, which will return into the 64 bit architecture. So, it will remove this error related to architecture mismatch between driver and the application.

如果您使用 Microsoft Office 2010,它将返回到 64 位架构。因此,它将消除与驱动程序和应用程序之间的架构不匹配相关的错误。

回答by ederollora

In my case, I had a 32 bit JDK 6u45 on a XP that used the jdbc:odbcdriver to query a .accdbfile. So I had a 32 bit JDK and also a 32 bit MS Office which automatically installed the necessary driver in my computer when I installed it. Then I moved the project to a Windows 7 with a Netbeans 7.3 with a 32 bit JDK 6u45 BUT a 64 bit MS Office 2013 so that seems to be the problem, If you have a 32 bit JDK installed then you need a 32bit version of Office (with the proper driver that comes with that Office version). And the same with 64 bit version.

就我而言,我在 XP 上有一个 32 位 JDK 6u45,它使用jdbc:odbc驱动程序来查询.accdb文件。所以我有一个 32 位的 JDK 和一个 32 位的 MS Office,当我安装它时,它会自动在我的电脑中安装必要的驱动程序。然后我将项目移至带有 Netbeans 7.3 和 32 位 JDK 6u45 但 64 位 MS Office 2013 的 Windows 7,因此这似乎是问题所在,如果您安装了 32 位 JDK,那么您需要 32 位版本的 Office (使用该 Office 版本附带的正确驱动程序)。与 64 位版本相同。

In my case I searched Oracle's Java archive for the 64 bit version of JDK6u45 and changed the JDK of the project to the 64 bit version.

就我而言,我在 Oracle 的 Java 存档中搜索了 64 位版本的 JDK6u45,并将项目的 JDK 更改为 64 位版本

回答by marcosn

I had the same problem and the solution, in my case, was to use a 32-bit JDK.

我遇到了同样的问题,就我而言,解决方案是使用 32 位 JDK。