简体   繁体   中英

Query returing no results codename one

Query showing no results and not giving any error .control not entering inside the if block help me out that where is the mistake i am doing ? i have tried many ways to get the result but all in vain. When i tried the following before the if statement

int column=cur.getColumnCount();
Row row=cur.getRow();
row.getString(0);

then i got the resultset closed exception

Database db=null;
Cursor cur=null;
System.out.print("Printing from accounts class "+Email+Password);
String [] param={Email,Password};
System.out.print(param[0]+param[1]);

try{
  db=Display.getInstance().openOrCreate("UserAccountsDB.db");
 cur= db.executeQuery("select * from APPUserInfo WHERE Email=? AND Password=?",(String [])param);
int   columns=cur.getColumnCount();
if(columns > 0) {

   boolean next = cur.next();
    while(next) {
      Row currentRow = cur.getRow();
      String LoggedUserName=currentRow.getString(0);
      String LoggedUserPassword=currentRow.getString(1);
      System.out.println(LoggedUserName);
      next = cur.next();
     }

   }
    }catch(IOException ex)
    {
   Util.cleanup(db);
   Util.cleanup(cur);
   Log.e(ex);
     }

   finally{
     Util.cleanup(db);
    Util.cleanup(cur);

     }

As @jobin said in the comments the cursor to the result appears before the first entry so until you invoke next() for the first time you don't have access to the data.

It seems that the table is empty which means there is no user in the DB matching email/password. Try removing the email/password clause to get a list of all the users to verify.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM