JDBC异常:Before start of result set

resultset的游标的起始位置是第一行前面,如果在这之前没有next()一下,就会出现如下异常:

 


Exception in thread "main" java.sql.SQLException: Before start of result set

    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)

    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)

    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)

    at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:835)

    at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5571)

    at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5491)

    at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5531)

 

解决办法:

 

while(rs.next()){         

            输出记录集内容......
      }

你可能感兴趣的:(thread,exception,jdbc)