I wrote a code to connect java and an Access file. The code works fine when run inside Netbeans 8.0 (JDK 1.7), but when I clean and build the same code and try to run the jar I keep getting error:
No suitable driver found for jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D:\SPOT.accdb
My Windows version : 64bit Microsoft Office: 32 bit, Java: 32 bit 1.7.0_79 Access DB engine: 32bit. I cannot use Office 64bit (Company Policy).
I have created a 32bit DSN but I feared that he is finding the 64 bit drivers so I tried to run the code from C:\Windows\SysWOW64 but got the same error.
Next I even set Application pool enable 32bit option.
Java Code:
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException ex) {
logger.severe(ex.getLocalizedMessage());
}
if (con == null) {
connURL = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + "D:\SPOT.accdb";
try {
con = DriverManager.getConnection(connURL, "", "");
} catch (SQLException ex) {
logger.severe(ex.getLocalizedMessage());
}
}