开发者

Unable to connect to MS Access database through JDBC on Win 7 64-bit

I've been trying to connec开发者_运维技巧t to a MS Access 2007 database through JDBC. My JDK is JDK 1.6u18 64-bit and OS is Windows 7 64-bit. But problem is I am unable to create a DSN using Windows\system32\odbcad32.exe because it doesn't show ODBC drivers for MS Access at all, it's only showing drivers for MS SQL Server.

When tried to click on Configure for "MS Access Database" (which is an already created DSN, I guess), it first shows error message : "The setup routines for the Microsoft Access Drivers (*.mdb, *.accdb) ODBC Driver could not be found. Please reinstall the driver." And then another message : "Errors found! The specified DSN contains an architecture mismatch between the Driver and Application."

I cannot reinstall the MDAC as it doesn't work with Windows 7 (which comes with its own WDAC).

The odbcad32.exe in Windows\SysWOW64 does let me create a DSN for MS Access, it shows the drivers installed properly. However, when tried to connect to that DSN through a Java program, I get the following exception :

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(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)
            at AccessTest.main(AccessTest.java:19)

What might be the problem and what do I have to do to get it working? My OS as well as JDK are 64-bit. Can't I connect to a Access 2007 database, which I presume is 32-bit? Any help would be highly appreciated. Also, in case one thinks this's not a right place for this question, I apologize in advance. Then please guide me to appropriate forum.

Another option would be to find a third-party JDBC driver for MS Access. But I do need to know what's wrong with my configuration. :-/

PS : I know there're many better databases available out there, but for few unfortunate reasons, I have to use MS Access only and have to get it working.


Have you looked at Access 2010 drivers? They work with 64 bit from what I've read.

http://www.microsoft.com/downloads/details.aspx?FamilyID=C06B8369-60DD-4B64-A44B-84B371EDE16D&displaylang=ja&displaylang=en


I have had this problem for a while too and I finally found a solution, so here it is for everybody else.

In order to set up the ODBC connection, I had to use the 32 bit version of odbcad32.exe that you can find in c:\windows\sysWOW64\odbcad32.exe, just like you did. I got my information from here: http://msdn.microsoft.com/en-us/library/ms712362%28v=vs.85%29.aspx

Just like you, once I did this my connection still gave the architecture mismatch error.

I figured that since the driver was a 32 bit driver, I could try to run my app using the 32 bit JVM. So, I downloaded the JRE 6U26 32 bit version, and everything started working correctly.

I hope this helps.


If you get the error on JDBC when running Windows 7 as mentioned above, its the Java 64 bit you installed instead of sticking to 32 bit. So install Java 6 32 bit JVM and everything back to normal again. This is providing you are running normal 32 bit MS Access like you used to.


if your jvm is 64 bit, you need a 64 bit ODBC driver. Use the 64 bit odbc administrator that you access from control panel and define your data source there. It should work...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜