IllegalArgumentException:索引1处的绑定值为null


67

有人知道这意味着什么吗?

12-31 20:55:45.861: ERROR/AndroidRuntime(12478): Caused by: java.lang.IllegalArgumentException: the bind value at index 1 is null
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:234)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.database.sqlite.SQLiteQuery.bindString(SQLiteQuery.java:182)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:48)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:330)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:280)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at net.lp.collectionista.providers.ProductContentProvider.query(ProductContentProvider.java:350)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.content.ContentProvider$Transport.query(ContentProvider.java:163)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.content.ContentResolver.query(ContentResolver.java:245)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at net.lp.collectionista.providers.FacadeContentProvider.query(FacadeContentProvider.java:563)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.content.ContentProvider$Transport.query(ContentProvider.java:163)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.content.ContentResolver.query(ContentResolver.java:245)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at net.lp.collectionista.util.ScanAddTask.existsProduct(ScanAddTask.java:164)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at net.lp.collectionista.util.ScanAddTask.<init>(ScanAddTask.java:71)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at net.lp.collectionista.util.ItemScanAddTask.<init>(ItemScanAddTask.java:34)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at net.lp.collectionista.ui.activities.collections.cd.CDCollectionViewWindow$MusicCDItemScanAddTask.<init>(CDCollectionViewWindow.java:147)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at net.lp.collectionista.ui.activities.collections.cd.CDCollectionViewWindow.restoreLocalState(CDCollectionViewWindow.java:1044)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at net.lp.collectionista.ui.activities.collections.cd.CDCollectionViewWindow.onRestoreInstanceState(CDCollectionViewWindow.java:966)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.app.Activity.performRestoreInstanceState(Activity.java:815)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1096)
12-31 20:55:45.861: ERROR/AndroidRuntime(12478):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2641)

3
这意味着您在某处有非法论点。大概是在某个不能为null的地方传递了null。
Falmarri 2010年

Answers:


195

The bind value显然是指selectionArgs您插入的选区query()。如果这样的selectionArgs值是null,则得到此值。


2
嗯,我明白这是一个古老的职位,但如果你要搜索NULL像我想在这里做什么:stackoverflow.com/questions/14175233/...
Scamparelli

2
我的问题是选择不完全正确。我错过了?,所以我不得不columnName来代替columnName +"=?"
WarrenFaith

对我而言,有些事情并没有立即显现出来:selectionArgs是一个数组,如果其中一个值为null,则会收到此错误。
詹森·哈特利

2

@Gray@pjv响应是为实现点是什么问题导致此错误。您必须谨慎选择和selectionArgs匹配,如果通过selection = nullselectionArgs = something,也会收到此错误!:)谢谢!


0

这与问题不完全相关,但是我面临着一个类似的问题argument containted a dash (-) at the beginning。这是造成问题的原因。

所以我逃避了这样的争论

return mDatabase.query(table_name,
                       null,
                       column_name + "=?",
                       new String[]{"\\" + argument},
                       null,
                       null,
                       null);

这为我解决了。

您还可以看到以下内容:如何在android的sqlite中转义特殊字符,例如'

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.