如何从64位JVM连接到32位Access数据库? [英] How to connect to a 32-bit Access Database from 64-bit JVM?

查看:229
本文介绍了如何从64位JVM连接到32位Access数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,当我不得不连接到32位Access数据库时,我只是使用32位JVM执行该应用程序。但是,我现在正在开发一个需要64位JVM的应用程序,但我仍然需要连接到32位Access数据库。当我尝试连接时,我得到这个异常:

So far, when I had to connect to an 32-bit Access Database, I simply executed the application using 32-bit 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. 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)

这是我的代码:

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


推荐答案

根据我的经验

对于用户(或系统?),ODBC DSN有单独的32位和64位定义。我想你可能有一个32位的
定义,但Java ODBC-Bridge正在寻找64位的定义。您不能从64位程序直接连接到
a 32位Access ODBC驱动程序(如果您尝试,则会收到错误信息)。

For User (or System ?) ODBC DSN's there are seperate 32 bit and 64 bit definitions. I think you probably have a 32 bit definition, but Java ODBC-Bridge is looking for the 64 bit definition. 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).

虽然Microsoft分发带有Windows的32位ODBC Microsoft Access驱动程序(32位和64位),它没有
使用Windows 64分发64位MsAccess驱动程序。有一个 64位访问ODBC驱动程序
可从Microsoft获得。下载和安装64位MsAccess驱动程序存在一些问题

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 a a 64 bit Access ODBC Driver available from Microsoft. There are some issues with downloading and installing the 64 bit MsAccess driver


  • 当我使用Java 6测试时,Java / Driver只能间歇性地工作( 64位);
    我还没有用Java 7测试它。
    使用java 6,我认为如果String字段位于SQL select语句的末尾,你可能没问题。
    我发现一些SQL语句有些没有。

  • 使用32位驱动程序,您确切知道驱动程序所在的位置,使用
    64位驱动程序,您不知道它将在何处安装。这使得自动安装
    脚本难以编写。

  • 您还需要创建单独的64位ODBC定义。

  • The Java / Driver only worked intermittently when I tested it with Java 6 (64 bit); 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. I found some SQL statements worked some did not.
  • 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. This makes automated installation scripts difficult to write.
  • You will also need to create separate 64 bit ODBC definitions.

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

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

另一方面,可能运行一个运行在32中的某个数据库代理/池包。 bit java
(并通过TCP / IP连接?)。我从来没有尝试过。

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 ?). I have Never tried it though.

Java 64 - >> DB代理运行32位Java DB - >> Ms Access

Java 64 -->> DB Proxy running 32 bit Java DB -->> Ms Access

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

像SSL-SQL-Proxy Server这样的东西可以工作

something like SSL-SQL-Proxy Server may work

祝你好运,希望有人可以为您提供解决方案

Good luck, hopefully some one can provide you with a solution

由于原始答案,有2个JDBC驱动程序

Since the original answer, there are 2 JDBC driver's

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

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

我还没试过

编辑:2014年5月8日

8th May 2014

看起来更商业化 Easysoft Driver HXTT驱动程序

文章可能有用

编辑2016年1月6日

Edit 6 Jan 2016

正如Gord Thompson所说; ODBC-Bridge已从Java 8中删除。好消息是 UCanAccess 正在积极开发中,他们似乎在稳步前进。

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.

这篇关于如何从64位JVM连接到32位Access数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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