java.sql.SQLException: Before start of result set
2014-09-26 14:01
288 查看
代码:
String myDriver="com.mysql.jdbc.Driver";
String url="jdbc:mysql://127.0.0.1:3306/bbs";
String sql = "select * from Article where id= 3";
try {
Class.forName(myDriver);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
conn=DriverManager.getConnection(url,"root","root");
Statement stmt=conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
System.out.print(rs.getString(1));
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
解决方法:
加上:rs.next()
String myDriver="com.mysql.jdbc.Driver";
String url="jdbc:mysql://127.0.0.1:3306/bbs";
String sql = "select * from Article where id= 3";
try {
Class.forName(myDriver);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
conn=DriverManager.getConnection(url,"root","root");
Statement stmt=conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
System.out.print(rs.getString(1));
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
解决方法:
加上:rs.next()
相关文章推荐
- java.sql.SQLException: Before start of result set异常
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set(转)
- java.sql.SQLException: Before start of result set解决方法
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set解决方法
- java.sql.SQLException: Before start of result set解决方法
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set
- 解决 java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set错误
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set异常及处理办法
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set的原因
- java.sql.SQLException: Before start of result set