views:

23

answers:

1

I'm dealing with an issue that has arisen for an application I've been working on which connects to a Access file via JDBC-ODBC. On other Windows platforms, this issue hasn't been encountered, but on Windows 7 64-bit boxes, attempting to connect with DSN-less connection strings return:

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Multiple variations on the string have been attempted, but all of them have returned the same error. Here's how it currently tries to connect:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

StringBuffer databaseConnectionString;

if (SystemUtils.IS_OS_WINDOWS_7) { databaseConnectionString = new StringBuffer("jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ="); databaseConnectionString.append(databaseFile);

} else { databaseConnectionString = new StringBuffer("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="); databaseConnectionString.append(databaseFile); databaseConnectionString.append(";DriverID=22;READONLY=false}"); }

Examining the driver in the 32-bit ODBC Data Source Admin confirms that the drivers are present. However, when regedt32.exe is used to examine ODBC drivers (HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBCINST.INI/ODBC Drivers), none of them appear.

Can anyone help to shed some light on this?

A: 

I found the problem was that I was running the program in 64-bit Java. Although I have yet to successfully have the program detect if it's running in 32-bit or 64-bit Java, I have solved the solution by installing a 32-bit Java runtime environment and using a .bat file that reads as follows:

@echo off

"C:\Program Files (x86)\Java\jre6\bin\java" -D32 -Xmx1024m -jar programName.jar

Thanks for the help!

DJScythe