showing exception: illegal operation on empty Result set
807591Jun 4 2008 — edited Jun 4 2008Hi All,
I have a problem regarding ResultSet.Its showing exception while deploying as
Exception java.sql.SQLEXCEPTION: illegal operation on empty result set.
But i entered username and password already.when i am retriving it in mysql its displaying.But i dont know why its shoing exception.please help me regarding that..My program is as follows:
public boolean check(String loginname,String loginpwd)
{
try{
int i=0;
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
con.setAutoCommit(false);
Statement s=con.createStatement();
System.out.println("select password from user where username="+loginname); ResultSet rs=s.executeQuery("select password from user where username=' "+loginname+" ' System.out.println("pwd is.."+rs.getString(1));
while(rs.next())
{
if((rs.getString(1)).equals("loginpwd"))
{
System. out.println("username exist..............");
return true;
}
else
return false;
}
return true;
}
catch (Exception e)
{
System.out.println("Exception"+e);
return false;
}
}