1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| E:\feba\testmysql.java:8: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
Class.forName("com.mysql.jdbc.Driver");
^
E:\feba\testmysql.java:9: unreported exception java.sql.SQLException; must be caught or declared to be thrown
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/test","root","root");
^
E:\feba\testmysql.java:10: unreported exception java.sql.SQLException; must be caught or declared to be thrown
Statement stmt = con.createStatement();
^
E:\feba\testmysql.java:11: unreported exception java.sql.SQLException; must be caught or declared to be thrown
ResultSet rs = stmt.executeQuery("select col1,col2 from tbl_test");
^
E:\feba\testmysql.java:12: unreported exception java.sql.SQLException; must be caught or declared to be thrown
while (rs.next()){
^
E:\feba\testmysql.java:13: unreported exception java.sql.SQLException; must be caught or declared to be thrown
String s = rs.getString("col1");
^
E:\feba\testmysql.java:14: unreported exception java.sql.SQLException; must be caught or declared to be thrown
String n = rs.getString("col2");
^
E:\feba\testmysql.java:17: unreported exception java.sql.SQLException; must be caught or declared to be thrown
rs.close();
^
E:\feba\testmysql.java:18: unreported exception java.sql.SQLException; must be caught or declared to be thrown
stmt.close();
^
E:\feba\testmysql.java:19: unreported exception java.sql.SQLException; must be caught or declared to be thrown
con.close(); |
Partager