[英]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驱动程序存在一些问题
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 Driver和HXTT 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.