I've run into a very annoying problem while trying to update some code. The code in question reads some (a lot actually) of info from a local MS access file (*.mdb), and then perform several operations on this data (just simple stuff). Keep in mind that I only need to read the db, nothing more.
The problem is that I'm triying to deploy this program to work in x64 operating systems (win7 mostly) and I can't access the 32-bit ODBC driver.
This is the part of the code that access the db, the variavle "path" is a string that contains the absolute path to the mdb file, as I said, this file is local.
public void openConection()
{
try
{
Properties props = new Properties();
props.put ("charSet", "ISO-8859-1");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dbURL = "jdbc:odbc:Driver={Microsoft AccessDriver (*.mdb)};DBQ=";
dbURL += this.path + ";DriverID=22;READONLY=false)";
this.connection = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft AccessDriver (*.mdb)};DBQ=" + this.path, props);
this.statement = this.connection.createStatement();
System.out.println("Success");
}catch(Exception e)
{
System.out.println("Error :" + e);
}
}
This throws the following error:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
The problem (as far as I can tell) is in this piece of code:
("jdbc:odbc:Driver={Microsoft AccessDriver (*.mdb)};DBQ=" + this.path, props
If I'm correct, this tries to bridge the java jdbc to MS Access ODBC, which is a 32 bit driver and therefore not accesible by the program. I tried googling my problem, but didn't find anything that could help, I did find a 64-bit MS Access driver, but it required uninstalling the 32-bit version of Office.
Also, I'd like to avoid having to create a DSN for this, as this program has to be given to a lot of people who would not know how to do that.
Thanks.
Zegpi