Search code examples
javamysqldbconnection

Could not load the driver java.sql.SQLException: No suitable driver found for jdbc


I have a problem with connecting my java and mysql database was working fine yesterday but now is not working here is my code.

public static void main(String[] args) {


    try 
    {
        Class.forName ("com.mysql.jdbc.Driver");
    }
    catch (ClassNotFoundException e)
    {
        System.out.println ("Could not load the driver");
    }

    String user, pass, host, database;
    user = "Michael";
    pass = "Blaine22";
    host = "localhost";
    database = "maintenance_work";

    Connection conn = DriverManager.getConnection
            ("jdbc:mysql://"+host+":3306/"+database, user, pass);

    conn.setAutoCommit(false);


    //Menu code:
    appSchoolMaintenance newWork = new appSchoolMaintenance();
    newWork.statement1(); // opens the start method


}

Solution

  • Started to work again - tried all the suggestions but started working again no rhyme or reason to it! thanks for the help though