java - How can I catch "no rows selected" in JSP? -
my jsp page contains following code 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 users username=? , password=?"); pstmt.setstring(1, "username"); pstmt.setstring(2, "password"); boolean iftrue=pstmt.execute(); system.out.println(""+iftrue); if (iftrue==false) { out.print("invalid userid , password combination"); } %>
now problem "the query returns no rows selected
oracle when putting invalid username , password combination , unable understand how can catch message. have tried using boolean, expected returning true
. not find method of pstmt returns string , executeupdate returns integer.
please try below code.
preparedstatement pstmt = con.preparestatement("select password users username=? , password=?"); pstmt.setstring(1, "username"); pstmt.setstring(2, "password"); resultset resultset = pstmt.executequery(); if(!resultset.next()) out.print("no rows selected"); }
Comments
Post a Comment