File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Windows 7 Access DB Connection Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Windows 7 Access DB Connection Error "Architecture Mismatch"" Watch "Windows 7 Access DB Connection Error "Architecture Mismatch"" New topic

Windows 7 Access DB Connection Error "Architecture Mismatch"

Will Barbee
Ranch Hand

Joined: Oct 01, 2008
Posts: 41
I am using Windows 7 and MS Access 2007 for a Java application.

First, to set up the ODBC connection, I had to use a 32-bit version of the Admin tools.
That is, odbcad32 in c:/windows/syswow64.
(See Microsoft SQL Server Developer forum entries.)
I then used the DB Name for the driver and also selected the DB itself for the driver.

I got it set up and followed some old code I had to connect to the DB.
After some initial errors, I am partially connecting which means that the code is correct, I think.
The code follows:

I have the following error message from the DriverManager.getConnection statement (#18 above):
"The specified DSN contains an architecture mismatch between the Driver and Application"

So there is some problem in my ODBC setup or in the DB. But what is it?
Jan Cumps

Joined: Dec 20, 2006
Posts: 2565

I think you analysis that this is a 32 vs 64 bits issue is right.

What happens if you set up a data source with c:\windows\system32\odbcad32.exe ?
That is bad advise. It doesn't work for Access.

OCUP UML fundamental and ITIL foundation
Will Barbee
Ranch Hand

Joined: Oct 01, 2008
Posts: 41
I forgot to say that I am using a fairly new Win7 and MS Office Professional 2007.
And that means Access is 2007.
And the code I have worked for Access 2003.

Yes, I think it is a 32-bit/64-bit issue.

The problem is that if you use the Control Panel / Admin Tools / Data Sources (ODBC) program,
you will only get (MS) SQL Server as a driver. To get MS Access drivers, you MUST use the 32-bit

The programs are getting through the Class.forName statement (Java ODBC Driver Name) OK.
But the DriverManager.getConnection gives the error.

Is there some glitch in Microsoft Win7 or Access 2007 (which costs minimum $159 to even talk to them)?
Or is there some disconnect in the sun.jdbc.odbc.JdbcOdbcDriver where 32-bit/64-bit
is connecting to Access 2007?
Matt Cartwright
Ranch Hand

Joined: Aug 25, 2008
Posts: 149

what architecture is your Java runtime?
Looks like you are running a 64-bit program
and try to load 32-bit libraries.

That does not work.

Either you install everything 32-bit, as you
did with your admin tools.

Or everything 64-bit, as your JVM probably is.

have a look here for the 32-bit version.

Hope that helps
Will Barbee
Ranch Hand

Joined: Oct 01, 2008
Posts: 41

Thank you.

I will try it as soon as I can.

Will Barbee
Ranch Hand

Joined: Oct 01, 2008
Posts: 41

As the British say, your recommendations were SPOT ON!

I reloaded Java for 32-bit and was running and testing within an hour.

Thank you.
I agree. Here's the link:
subject: Windows 7 Access DB Connection Error "Architecture Mismatch"
It's not a secret anymore!