0
當我嘗試編譯無法連接到我的數據庫
ConnectDB.java:14: error: unreported exception ClassNotFoundException; must be caught or declared to be thrown
Class.forName("com.mysql.jdbc.Driver");
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
public class ConnectDB
{
public ConnectDB() throws SQLException
{
Class.forName("com.mysql.jdbc.Driver");
Connection dbConnect = DriverManager.getConnection("jdbc:mysql://xx.xx.xxx.xxx:3306/my_DB", "userName", "superSecurePassword");
}
}
我已經下載並安裝驅動程序,並設置類路徑,但繼續得到錯誤,我得到這個錯誤。