samedi 3 janvier 2015

Android SQLiteException: bind or column index out of range: handle 0x2a0b88

I am getting this error, when try to execute query below query- Also I am passing the values (uname,pass) from other java class. I tried to search the data in the table for both the values ie I am using both the parameters to search the data.



public boolean validate(String uname, String pass) {
// TODO Auto-generated method stub

// SELECT
String[] columns = { "_id" };

// WHERE clause
String selection = "user_name = ? AND _password";

// WHERE clause arguments
String[] selectionArgs = { uname, pass };

Cursor cursor = ourDatabase.query(DATABASE_TABLE, columns, selection,
selectionArgs, null, null, null);
try {
if (cursor != null && cursor.getCount() > 0) {
return true;
}
} catch (Exception e) {
e.printStackTrace();

}

return false;

}


Also, Please find the below logcat-



01-04 01:08:10.582: E/AndroidRuntime(1180): FATAL EXCEPTION: main
01-04 01:08:10.582: E/AndroidRuntime(1180): android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x2a0b88
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.database.sqlite.SQLiteProgram.native_bind_string(Native Method)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:241)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.database.sqlite.SQLiteQuery.bindString(SQLiteQuery.java:182)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:48)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1229)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1184)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1264)
01-04 01:08:10.582: E/AndroidRuntime(1180): at com.example.retailapp.Database.validate(Database.java:139)
01-04 01:08:10.582: E/AndroidRuntime(1180): at com.example.retailapp.User.onClick(User.java:63)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.view.View.performClick(View.java:2408)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.view.View$PerformClick.run(View.java:8816)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.os.Handler.handleCallback(Handler.java:587)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.os.Handler.dispatchMessage(Handler.java:92)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.os.Looper.loop(Looper.java:123)
01-04 01:08:10.582: E/AndroidRuntime(1180): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-04 01:08:10.582: E/AndroidRuntime(1180): at java.lang.reflect.Method.invokeNative(Native Method)
01-04 01:08:10.582: E/AndroidRuntime(1180): at java.lang.reflect.Method.invoke(Method.java:521)
01-04 01:08:10.582: E/AndroidRuntime(1180): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-04 01:08:10.582: E/AndroidRuntime(1180): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-04 01:08:10.582: E/AndroidRuntime(1180): at dalvik.system.NativeStart.main(Native Method)

Aucun commentaire:

Enregistrer un commentaire