*
The moose likes JDBC 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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Windows 7 Access DB Connection Error "Architecture Mismatch"" Watch "Windows 7 Access DB Connection Error "Architecture Mismatch"" New topic
Author

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
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

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
youtube channel
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
program.

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
Matt
Will Barbee
Ranch Hand

Joined: Oct 01, 2008
Posts: 41
Matt:

Thank you.

I will try it as soon as I can.

WillB
Will Barbee
Ranch Hand

Joined: Oct 01, 2008
Posts: 41
Matt:

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: http://aspose.com/file-tools
 
subject: Windows 7 Access DB Connection Error "Architecture Mismatch"
 
Similar Threads
JDBC problems using Servlets
Win7 MSAccess Cannot get DB Connection
connecting to Webtrends reporting DB using JDBC-ODBC
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
MySQL Communications Error between application server and MySQL server