Search code examples
javams-accessucanaccess

Exception: java.sql.SQLException: No suitable driver found for jdbc:ucanaccess


Getting exception in my java code

Exception: java.sql.SQLException: No suitable driver found for jdbc:ucanaccess:C:\Users\mindurka\Desktop\SeleniumWorkspace\TestCaseSheet\TestCaseSheet.mdb;

         Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
         System.setProperty("DUCANACCESS_HOME","C:/Users/mindurka/Downloads/Selenium3.4/UCanAccess-4.0.2-bin/UCanAccess-4.0.2-bin");

         String connURL = "jdbc:ucanaccess:"+TestCaseSheetPath+";";
         Connection objAccessCon = DriverManager.getConnection(connURL);

Have included all the five jars in the source folder in my library set

C:\UCanAccess-4.0.2-bin\UCanAccess-4.0.2-bin

I do not understand the reason behind this. Kindly help.


Solution

  • jdbc:ucanaccess:C:\Users\mindurka\Desktop\SeleniumWorkspace\TestCaseSheet\TestCaseSheet.mdb
    

    is not a valid connection URL. It needs to begin with

    jdbc:ucanaccess://
    

    followed by the path to the database file.