connecting to jdbc driver issue (Still a newbie to java)

I've established a connection through a BASIS JDBC driver using the database window by adding the driver.  This has allowed me to generate my ORM maps etc.

I am now trying to connect to the database via java code and keep getting the following message

java.sql.SQLException: No suitable driver found for jdbc:basis:east3.ihmsweb.com:2001?DATABASE=BBJ_IHMS_WEG

I am assuming it is a CLASSPATH issue, but I have no idea how to add the driver to the project.  I did try adding the drivers jar file in the Project Structure dialog to the module dependencies as well as the library.  This action did not change the outcome.

Any help would be greatly appreciated.

Ian

2 comments

Hate posting answers to my own questions but...

Original code was

   try(Connection connection = DriverManager.getConnection(dbURL, properties)){

            JOptionPane.showMessageDialog(null, "Success!");
        }
        catch(SQLException e){
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "Nope!");
            System.exit(0);
        }


had to add code for Class.forName as follows

        try{
            Class.forName("com.basis.jdbc.BasisDriver");
            JOptionPane.showMessageDialog(null, "Class found!");
        }
        catch(ClassNotFoundException e){

            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "Nope!  Class not found");
            System.exit(0);
        }

        // Everything is ready?? Let's try the connection
        try(Connection connection = DriverManager.getConnection(dbURL, properties)){

            JOptionPane.showMessageDialog(null, "Success!");
        }
        catch(SQLException e){
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "Nope!");
            System.exit(0);
        }
0

Please sign in to leave a comment.