我想通過遵循將Apache Wicket Web應用程序連接到MySQL數據庫所需的所有步驟來解決此問題。錯誤:java.lang.ClassNotFoundException:com.mysql.jdbc.Driver
step1右鍵點擊項目 - > Build Path - > Configure Build Path - > Java Build Path - > Libraries Tab - > Add external jar - >然後我瀏覽MySql-Connector-5.0.8 jar文件。
第二步在節目我寫下
public static Connection con=null;
public static Connection getConnection()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/db1", "root", "root");
}catch(ClassNotFoundException ex){ex.printStackTrace();}
catch(SQLException e){System.out.println(e);}
finally{
try
{
con.close();
}catch(Exception e){}
}
return con;
}
,但仍然面臨着錯誤的拋出java.lang.ClassNotFoundException:com.mysql.jdbc.Driver 現在什麼do..I需要你的幫助
檢查您是否在庫下有'MySql-Connector-5.0.8.jar'。如果它不在那裏可能會損壞ref,請嘗試將其添加到項目 – 2014-11-21 11:50:55
是的,它是在庫下..我應該添加MySql的依賴關係在POM.xml ..? – 2014-11-21 11:55:21