2016-11-04 70 views
2

查詢顯示沒有結果並且沒有提供任何錯誤.control不會進入if區塊內部幫助我解決我在哪裏犯的錯誤? 我已經嘗試了很多方法來獲得結果,但都是徒勞的。當我嘗試過的if語句查詢沒有發現任何結果codename一

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

那麼下面我得到的結果集關閉例外

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); 

    } 
+0

你能通過直接打db獲得任何結果嗎? –

+0

嘗試把行「boolean next = cur.next();」之前「int columns = cur.getColumnCount();」 – Jobin

+0

columnCount()返回6,但每當在「boolean next = cur.next()」行時,它返回false並且不進入while循環,並且在while循環之前我試圖獲得該行,然後引發以下異常 – Yasir

回答

0

正如@jobin說,在評論光標到結果中的第一項,直到出現之前你首次調用next()您無權訪問數據。

看起來表格是空的,這意味着DB中沒有用戶匹配電子郵件/密碼。嘗試刪除電子郵件/密碼子句以獲取要驗證的所有用戶的列表。

+0

沒錯@ shai almog謝謝我有我的表格列錯誤 – Yasir