简体   繁体   English

如何从64位JVM连接到32位Access数据库?

[英]How to connect to a 32-bit Access Database from 64-bit JVM?

So far, when I had to connect to an 32-bit Access Database, I simply executed the application using 32-bit JVM. 到目前为止,当我不得不连接到32位Access数据库时,我只是使用32位JVM执行应用程序。 However, I am now developing an application that requires 64-bit JVM, but I still need to connect to an 32-bit Access Database. 但是,我现在正在开发一个需要64位JVM的应用程序,但我仍然需要连接到32位Access数据库。 When I am trying connect, I get this exception: 当我尝试连接时,我得到以下异常:

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)

This is my code: 这是我的代码:

String s = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + path;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(s, user, password);

From my experience 根据我的经验

For User (or System ?) ODBC DSN's there are seperate 32 bit and 64 bit definitions. 对于用户(或系统?)ODBC DSN,有单独的32位和64位定义。 I think you probably have a 32 bit definition, but Java ODBC-Bridge is looking for the 64 bit definition. 我想你可能有32位的定义,但Java ODBC-Bridge正在寻找64位的定义。 You can not directly connect to a 32 bit Access ODBC driver from a 64 bit program (you get an error saying this if you try). 您无法从64位程序直接连接到32位Access ODBC驱动程序(如果您尝试,则会收到错误信息)。

While Microsoft distributes 32 bit ODBC Microsoft Access Drivers with Windows (32 & 64 bit), it does not distribute 64 bit MsAccess drivers with Windows 64. There is aa 64 bit Access ODBC Driver available from Microsoft. 虽然Microsoft使用Windows(32位和64位)分发32位ODBC Microsoft Access驱动程序,但它不会使用Windows 64分发64位MsAccess驱动程序 .Microsoft提供了64位Access ODBC驱动程序 There are some issues with downloading and installing the 64 bit MsAccess driver 下载和安装64位MsAccess驱动程序存在一些问题

  • The Java / Driver only worked intermittently when I tested it with Java 6 (64 bit); 当我用Java 6(64位)测试时,Java / Driver只能间歇性地工作; I have not tested it with Java 7. With java 6, I think you may be OK if String fields are at the end of SQL select statments. 我没有用Java 7测试它。对于java 6,我认为如果String字段位于SQL select语句的末尾,你可能没问题。 I found some SQL statements worked some did not. 我发现一些SQL语句有些没有。
  • with the 32 bit driver, you know exactly where there driver is located, with 64 bit driver you do not know where it will be installed. 使用32位驱动程序,您确切知道驱动程序所在的位置,使用64位驱动程序时您不知道它将安装在何处。 This makes automated installation scripts difficult to write. 这使得自动安装脚本难以编写。
  • You will also need to create separate 64 bit ODBC definitions. 您还需要创建单独的64位ODBC定义。

    =============================================== ===============================================

On a different note, It may be possible to run a some Database Proxy/Pooling package running in a 32 bit java (and connect via TCP/IP ?). 另外,有可能运行一个在32位java中运行的数据库代理/池包(并通过TCP / IP连接?)。 I have Never tried it though. 我从来没有尝试过。

Java 64 -->> DB Proxy running 32 bit Java DB -->> Ms Access Java 64 - >> DB Proxy运行32位Java DB - >> Ms Access

Database Proxy List: http://www.manageability.org/blog/stuff/jdbc-proxy-drivers 数据库代理列表: http//www.manageability.org/blog/stuff/jdbc-proxy-drivers

something like SSL-SQL-Proxy Server may work 像SSL-SQL-Proxy Server这样的东西可能会起作用

Good luck, hopefully some one can provide you with a solution 祝你好运,希望有人可以为你提供解决方案


Since the original answer, there are 2 JDBC driver's 从最初的答案来看,有2个JDBC驱动程序

Open Source: http://ucanaccess.sourceforge.net/site.html 开源: http //ucanaccess.sourceforge.net/site.html

Commercial: http://www.csv-jdbc.com/stels_mdb_jdbc.htm 商业: http //www.csv-jdbc.com/stels_mdb_jdbc.htm

I have not tried either 我也没试过


Edit: 8th May 2014 编辑:2014年5月8日

Looks to be more commercial drivers Easysoft Driver and HXTT Driver 看起来更像是商业驱动程序Easysoft DriverHXTT Driver

This Article may be useful 可能是有用的


Edit 6 Jan 2016 编辑2016年1月6日

As Gord Thompson says; 正如戈德汤普森所说; the ODBC-Bridge has been removed from Java 8. The good news is UCanAccess is being actively developed and they seem to making steady progress. ODBC-Bridge已从Java 8中删除。好消息是UCanAccess正在积极开发,它们似乎正在取得稳步进展。

Now that the JDBC-ODBC Bridge has been removed from Java 8 all of these issues surrounding Access ODBC will increasingly become a thing of the past and a "real" JDBC driver will be required. 现在已经从Java 8中删除了JDBC-ODBC Bridge,围绕Access ODBC的所有这些问题将日益成为过去,并且将需要“真正的”JDBC驱动程序。

As mentioned in an earlier answer, UCanAccess is a free open-source option. 正如之前的回答中所提到的, UCanAccess是一个免费的开源选项。 It is a pure Java implementation that does not use ODBC at all, so it will work regardless of the platform (Windows, Linux, ...) or architecture (32-bit or 64-bit). 它是一个完全不使用ODBC的纯Java实现,因此无论平台(Windows,Linux,...)还是体系结构(32位或64位)都可以使用它。

For more information on using UCanAccess, see the related question here . 有关使用UCanAccess的更多信息,请参阅此处的相关问题。

The problem is that you should run on Java 32 bit try to install latest JDK and it will work 问题是你应该运行Java 32位尝试安装最新的JDK,它会工作

I run it using JDK version "jdk-7u67-windows-i586.exe" 我使用JDK版本“jdk-7u67-windows-i586.exe”运行它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 这是32位还是64位JVM? - Is this is a 32-bit or 64-bit JVM? 安装了 32 位和 64 位 JVM 时,如何使用 32 位 JVM 强制运行 Jar 文件? - How to forcefully run a Jar file using 32-bit JVM when both 32-bit and 64-bit JVM are installed? 如何判断我是在 64 位 JVM 还是 32 位 JVM 中运行(从程序中)? - How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)? 64位Java无法通过ODBC访问32位MS Access数据库 - 64-bit Java can't access 32-bit MS Access database via ODBC 如何从 64 位 Java 连接到 Access .mdb 数据库? - How to connect to Access .mdb database from 64-bit Java? 无法在具有32位JVM的AMD 64位平台上加载IA 32位.dll - Can't load IA 32-bit .dll on a AMD 64-bit platform with 32 bit JVM 服务器上的64位JVM,客户端上的32位JVM,可以组合吗? - 64-bit JVM on Server, 32-bit JVM on Client, combination possible? 可以通过参数“-d32”强制64位JVM使用32位模式? - possible to force a 64-bit JVM to use 32-bit mode via the argument “-d32”? 无法在32位JVM上加载64位SWT库(即使我下载了32位SWT) - Cannot load 64-bit SWT libraries on 32-bit JVM (even though I downloaded 32-bit SWT) "如何从 32 位 C++ 应用程序启动 64 位 Java 应用程序?" - How to start 64-bit Java application from 32-bit C++ application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM