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

查看:27
本文介绍了如何从 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 位程序的 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 和 64 位)分发 32 位 ODBC Microsoft Access 驱动程序,但它没有使用 Windows 64 分发 64 位 MsAccess 驱动程序.有一个 64 位访问 ODBC 驱动程序可从微软获得.下载安装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/驱动程序仅在我使用 Java 6(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 位 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 -->> 运行 32 位 Java DB 的数据库代理 -->> Ms Access

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

数据库代理列表:http://www.manageability.org/blog/东西/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 DriverHXTT 驱动程序

Looks to be more commercial drivers Easysoft Driver and HXTT Driver

这个 文章 可能有用

编辑 2016 年 1 月 6 日

Edit 6 Jan 2016

正如戈德汤普森所说;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天全站免登陆