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

Posted by Ninad on Stack Overflow See other posts from Stack Overflow or by Ninad
Published on 2010-02-26T21:08:43Z Indexed on 2010/05/19 15:00 UTC
Read the original article Hit count: 429

Filed under:
|

Hello.

I've been trying to connect 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.

© Stack Overflow or respective owner

Related posts about jdbc

Related posts about ms-access-2007