import java.sql.Connection;
public static void main(String[] args) throws SQLException, RuntimeException {
try{
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
String connectionURL="jdbc:mysql://localhost:3306/aaa?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
String login="root";
String password="aaa";
try (Connection conn = DriverManager.getConnection(connectionURL, login, password)) {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM Lista1");
while(rs.next()) {
System.out.println(rs.getString("nazwa"));
}
rs.close();
stmt.close();
}
}
catch(SQLException e) {
System.out.println("Blad polaczenia:");
e.printStackTrace();
}
catch(RuntimeException e) {
System.out.println("Blad polaczenia:");
e.printStackTrace();
}
The console log throws:
Exception in thread "main" java.lang.RuntimeException:
at cccc.web.Main.main(Main.java:1)
I tried to delete return, but it still threw bad issue. I tried many things but I don't know how to fix it. I don't know how to solve it. And I spent many many many times to fight with it!!!!