Menu

No connection and without a reason

Help
2019-11-28
2019-11-28
  • Paolo Parise

    Paolo Parise - 2019-11-28

    Hi,
    I have problem connecting to a database, and no exceptions are raised.

    This is my class.

    public class db {
    
        Connection connection;
        static
        {
            try {
                Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
                System.out.println("driver ok");
            } catch (ClassNotFoundException e) {
                System.out.println("the class driver cannot be loaded");
            }
        }
    
        public Connection connect(String database_name) throws SQLException 
        {
            String filename = io.PATH_DB + database_name + ".mdb";
            String database = "jdbc:ucanaccess://";
            database += filename.trim();
            System.out.println(database);
            try
            {
                connection = DriverManager.getConnection(database); 
                System.out.println("Ok connection");
            }
            catch(Exception e)
            {
                io.error("Connessione al database " + database_name + " non riuscita");
                connection = null;
                System.out.println(e);  
                e.printStackTrace();
            }
            return connection;
        }
    

    drivers and libraries are ok, as I can see in the console, I can see the connection string that is
    jdbc:ucanaccess://C:\Users\paolo.SCRIPTA\YandexDisk\java\base\database\pagheorg.mdb
    and I cannot see console log "ok connection" but even any fault trace.

    It seems that the execution stops on getConnection row.

    What am I doing wrong? Is it a normai behaviour?
    I'm using 4.0.4 version.

    Thank you!

     

    Last edit: Paolo Parise 2019-11-28
  • Paolo Parise

    Paolo Parise - 2019-11-28

    It is only very slow in execution, my fault. It works.

     

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.