how to run java app on 32bit OS
Hello all,
I am having issues connecting to my database on a 64 bit OS (windows 7). I have run and compiled this code on other machines and it works fine but my 64bit OS will not connect. I do have Access/Office installed, but when I check the 64bit DSN the drivers are not installed (and there are not drivers available to install them) but in the 32bit DSN they are. Also, I know the path to the DB is correct. I'd rather not create a OS specific program, as that kind of defeats the purpose of programming in java but i dont know what else to do. Interestingly, though, I dont have this problem when i program in Visual Studio. Anyway, here's the code I'm using to connect:
Code:
public Connection connectToDatabase(String dbName) throws Exception {
if (conn != null) {
return conn;
}
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
if (System.getProperty("java.vendor").equals("Microsoft Corp.")) {
//Microsoft VM users
driver = "com.ms.jdbc.odbc.JdbcOdbcDriver";
}
String curDir = System.getProperty("user.dir");
String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="
+ curDir
+ "\\"
+ dbName;
String username = "";
String password = "";
Class.forName(driver);
System.out.print(url);
return DriverManager.getConnection(url, username, password);
}
As i mentioned above, the code works fine on other, non 64 bit/windows 7 machines. the error i get is:
run:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
and my connection string, when printed out, looks like this:
jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\Users\Delerium\Documents\NetBeans Projects\MyDatabaseProgram\MyClients.accdb
Any help would be great. This problem has left me dead in the water and I am unable to complete my work.
thanks
jason