1

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());
                }
             }
Anuja
  • 349
  • 3
  • 14
  • 3
    Possible duplicate of [java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver Exception occuring. Why?](http://stackoverflow.com/questions/22984438/java-lang-classnotfoundexception-sun-jdbc-odbc-jdbcodbcdriver-exception-occurin) – Petter Friberg Dec 04 '15 at 15:10
  • Have your application display the string returned by `System.getProperty("java.version")`. What does it show when you run your app from the JAR file? – Gord Thompson Dec 04 '15 at 15:45
  • Java: 32 bit 1.7.0_79 – Anuja Dec 07 '15 at 10:50
  • It is not a duplicate because I cannot use jackcess which was the solution suggested on the previous question. – Anuja Dec 23 '15 at 12:52

0 Answers0