次のサーブレット スニペット:
ResultSet set = statement.executeQuery();
// userName = set.getString(1);
if(set.next()) {
userName = set.getString("FirstName");
Email = set.getString("Email");
}
if(set.wasNull()) { //<<------------- line 33
// turn to the error page
response.sendRedirect("LoginFailure.jsp");
} else {
// start the session and take to his homepage
HttpSession session = request.getSession();
session.setAttribute("UserName", userName);
session.setMaxInactiveInterval(900); // If the request doesn't come withing 900 seconds the server will invalidate the session
RequestDispatcher rd = request.getRequestDispatcher("portfolio_one.jsp");
rd.forward(request, response); // forward to the user home-page
}
次の例外を作成します。
INFO: java.sql.SQLException: Invalid operation: wasNull() called with no data retrieved.
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.ResultSet.wasNull(Unknown Source)
at com.sun.gjc.spi.base.ResultSetWrapper.wasNull(ResultSetWrapper.java:141)
--------->> at projectcodes.ValidateDataForSignIn.doPost(ValidateDataForSignIn.java:33)
..........
なぜこの例外が発生するのですか? 強調表示された行が原因で例外が発生します: 33