. Advertisement .
..3..
. Advertisement .
..4..
The error: java.sql.sqlexception: before start of result set appears to me. I’m worried because I have no experience with this problem. Everyone’s help will be very valuable to me. What is the cause of the error and how to fix it? Hope to receive your reply soon. Thanks in advance.
This is my error code:
try
{
userID = resultSet.getInt(0);
System.out.println(resultSet.toString()+"222");
}
catch (SQLException e1) {
e1.printStackTrace();
}
The cause:
java.sql.sqlexception: before start of result set error occurs because of the following reason:
The cursor jumps one line per time the next() method is used. Since it is initially situated before the first line, the first use of next() should make the first line the current line. The cursor will advance one line with each call to next(). The cursor is active until the parent Statement object and child ResultSe object are closed.
Solution: Prior to actually adding
rs.next()
, you should users.getString()
.Exact code: