我有一個問題,連接我的java和mysql數據庫昨天工作正常,但現在不在這裏工作是我的代碼。無法加載驅動程序java.sql.SQLException:找不到合適的驅動程序jdbc
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
}
您已經不需要Class.forName()行大約十年。只要刪除它。您可能會再次得到另一個錯誤,或者再次出現相同的錯誤,但這次至少您會運行最新的代碼。 – EJP
@EJP>你提供連接池嗎? – mok
這是你昨天運行的項目嗎? – mok