Menu

Gailed to get DB Connection

Help
2017-12-14
2017-12-15
  • Will Barbee

    Will Barbee - 2017-12-14

    Using Windows 10. Environment variables set to (with appropriate paths) -
    ucanaccess-4.0.2.jar
    commons-lang-2.6.jar
    commons-logging-1.1.1.jar
    hsqldb.jar
    jackcess-2.1.6.jar

    Program has run previously using other folders.
    Call instructions are -
    String strDBName = "jdbc:ucanaccess://c:/WillPgms/Family Genealogy.accdb";
    DAO_Conn = DriverManager.getConnection(strDBName);
    DAO_Indiv = DAO_Conn.createStatement();
    }
    catch (Exception e)
    {
    System.out.println("Indiv: Failed to get DB connection");
    }

    And I get the error "Failed to get DB connection".

    I have checked and the Family Genealogy.accdb is in that directory.

    What have I missed? Do the .jar's have to be in the same folder?

     
  • Gord Thompson

    Gord Thompson - 2017-12-14

    Please use e.printStackTrace to capture the actual error message with context and post it here.

     
  • Will Barbee

    Will Barbee - 2017-12-15

    Thx, Gord. Will do. (pun?)

     
  • Will Barbee

    Will Barbee - 2017-12-15

    Haven't been able to get printStackTrace() to go to file during execute - it stays in DOS window.
    Anyway, the error is "java,sql.Exception: No suitable driver found for jdbc:ucanaccess ... db-name..."
    The program statement referenced is DAO_Conn = DriverManager.getConnection(strDBName);
    JPG of DOS window attached.
    Let me know if you need more...

     
  • Will Barbee

    Will Barbee - 2017-12-15

    SOLVED! I went back and double-checked all entries.
    I had moved the UCanAccess modules to another folder and the Environment Variables pointed to the wrong folder. Thus: "No suitable driver found" error.
    Thanks for your help. I learn something new every day.

     
  • Gord Thompson

    Gord Thompson - 2017-12-15

    The UCanAccess driver jar file is not on the classpath. I have unpacked the bin.zip to C:\Users\Public\Downloads\UCanAccess so my jar file paths are

    C:\Users\Public\Downloads\UCanAccess\ucanaccess-4.0.2.jar
    C:\Users\Public\Downloads\UCanAccess\lib\commons-lang-2.6.jar
    C:\Users\Public\Downloads\UCanAccess\lib\commons-logging-1.1.1.jar
    C:\Users\Public\Downloads\UCanAccess\lib\hsqldb.jar
    C:\Users\Public\Downloads\UCanAccess\lib\jackcess-2.1.6.jar
    

     
    So, if I try to simply run java PrgTrXSt I get

    java.sql.SQLException: No suitable driver found for jdbc:ucanaccess://C:/Users/Public/UCanAccessTest.accdb
            at java.sql.DriverManager.getConnection(Unknown Source)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at PrgTrXSt.main(PrgTrXSt.java:6)
    

     
    However, this works:

    java -cp .;/Users/Public/Downloads/UCanAccess/*;/Users/Public/Downloads/UCanAccess/lib/* PrgTrXSt
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.