so i have declared an SQL connection like below :
public class db {
public void run() throws SQLException {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/project", "rizkiaswangga", "");
} catch (SQLException e) {
System.out.println(e.getMessage());
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
i'm just trying to connect MariaDB to my Java project firstly, but although i have declared SQLException, i still encounter an error message like below :
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable code - unreported exception java.sql.SQLException; must be caught or declared to be thrown
when i try to run from other class :
public class Start extends javax.swing.JFrame {
/**
* Creates new form Start
*/
public Start() {
initComponents();
db myDb = new db();
myDb.run();
}
what is wrong on my code? any help would be appreciated :)