My JSP page contains the following code for login authentication:
<%
System.out.println("Entered");
String username=request.getParameter("username");
String password=request.getParameter("password");
Connection con=getConnection.getConnectionBuilder();
PreparedStatement pstmt=con.prepareStatement("Select password from users where username=? and password=?");
pstmt.setString(1, "username");
pstmt.setString(2, "password");
boolean ifTrue=pstmt.execute();
System.out.println(""+ifTrue);
if (ifTrue==false)
{
out.print("Invalid userid and password combination");
}
%>
Now the problem is "The query returns no rows selected
from Oracle when I am putting invalid username and password combination and I am unable to understand how can I catch this message. I have tried using Boolean, but as expected it is returning true
. I could not find any method of pstmt which returns string and executeUpdate returns integer.