ERROR: failed to load JDBC driver - org.hsqldb.jdbcDriver

Posted by maximus on Stack Overflow See other posts from Stack Overflow or by maximus
Published on 2012-09-21T15:26:03Z Indexed on 2012/09/21 15:37 UTC
Read the original article Hit count: 421

Filed under:
|
|
|

i wrote a connector class to connect to the hsqldb.

here is my code:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.apache.log4j.Logger;


public class hsqlmanager {

        private static final Logger log = Logger.getLogger(hsqlmanager.class);

        private static Connection con=null;

        private static void openConnection(){
            try {
                Class.forName("org.hsqldb.jdbcDriver" );
                log.info("Loaded JDBC Driver");
            } 
            catch (Exception e) {
                log.error("ERROR: failed to load JDBC driver - " + e.getMessage());
                return;
            }

            try {
                con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/sepm_db","sa","");      
            }
            catch(SQLException e){
                log.error(e.getMessage());
            }
        }

        public static void closeConnection() {
            try {
                con.close();
            }
            catch(SQLException e) {
                log.error(e.getMessage());
            }
        }

        public static Connection getConnection() {
            if (con==null){
                openConnection();
            }
            else {
                try {
                if(con.isClosed()){
                    con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/sepm_db","sa","");

                }
                }
                catch(SQLException e){
                    log.error(e.getMessage());
                    return null;
                }
            }

            return con;
        }

}

When I compile that I get ERROR: failed to load JDBC driver - org.hsqldb.jdbcDriver. Why?

© Stack Overflow or respective owner

Related posts about java

Related posts about database