Can somebody please tell me how to fix the error on line 8 of my Test class I have no idea wtf is wrong with it or how to even search for solution
Main class
package T;
public class Test {
public static void main(String[] args) {
SQL sql = new SQL();
sql.getData();//Error here "Unreported exception Exception; must be caught or declared to be thrown"
}
}
SQL Class
package T;
public class SQL {
private Connection connect = null;
public String getData() throws Exception {
String name = null;
try {
Class.forName("com.mysql.jdbc.Driver");
connect = DriverManager.getConnection("jdbc:mysql://localhost/vehicles?" + "user=sqluser&password=sqluserpw");
Statement st = connect.createStatement();
ResultSet rs = st.executeQuery("SELECT * from vehicles.test");
if (rs.next()) {
name = rs.getString("word");
}
return name;
}
catch (Exception e) {
throw e;
}
}
}