android.database.sqlite.SQLiteException:near“(”

时间:2011-09-27 06:49:00

标签: android sql database

这是我的错误:

09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1149)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1802)
09-27 08:16:34.557: WARN/System.err(8366):     at de.enough.appmate.dbase.CMSResource.updateItem(CMSResource.java:1168)
09-27 08:16:34.557: WARN/System.err(8366):     at de.enough.appmate.dbase.CMSResourceUpdater.updateItems(CMSResourceUpdater.java:179)
09-27 08:16:34.557: WARN/System.err(8366):     at de.enough.appmate.dbase.CMSResourceUpdater.loadUpdates(CMSResourceUpdater.java:102)
09-27 08:16:34.557: WARN/System.err(8366):     at de.enough.appmate.dbase.CMSResourceUpdaterRunnable.run(CMSResourceUpdaterRunnable.java:32)
09-27 08:16:34.557: WARN/System.err(8366):     at java.lang.Thread.run(Thread.java:1019)

这是我的updateItem方法代码,应该更新数据库:

this.db.execSQL("UPDATE " + CMSConstants.ITEMS + " SET ( " +
                    CMSConstants.ID + ", " +
                    CMSConstants.TITLE + ", " +
                    CMSConstants.IS_PAGE + ", " +
                    CMSConstants.IS_HIDDEN + ", " +
                    CMSConstants.ITEM_TYPE + ", " +
                    CMSConstants.ORDER_INDEX + ", " +
                    CMSConstants.SECTION_ID + ", " +
                    CMSConstants.TABLE_SECTION_NAME + ", " +
                    CMSConstants.TABLE_SECTION_ID + ", " +
                    CMSConstants.IMAGE1_FILE + ", " +
                    CMSConstants.IMAGE1_CAPTION + ", " +
                    CMSConstants.IMAGE1_DISPLAY_IN_GALLERY + ", " +
                    CMSConstants.CATEGORY1 + ", " +
                    CMSConstants.CATEGORY2 + ", " +
                    CMSConstants.GEO_LONGITUDE + ", " +
                    CMSConstants.GEO_LATITUDE + ", " +
                    CMSConstants.DESCRIPTION + ", " +
                    CMSConstants.KEYWORDS + ", " +
                    CMSConstants.BLOCKWORDS + ", " +
                    CMSConstants.CLEAN_NAME + ", " +
                    CMSConstants.ADDITIONAL_FIELD1_NAME + ", " +
                    CMSConstants.ADDITIONAL_FIELD1_VALUE + ", " +
                    CMSConstants.ADDITIONAL_FIELD2_NAME + ", " +
                    CMSConstants.ADDITIONAL_FIELD2_VALUE + ", " +
                    CMSConstants.ADDITIONAL_FIELD3_NAME + ", " +
                    CMSConstants.ADDITIONAL_FIELD3_VALUE + ", " +
                    CMSConstants.ADDITIONAL_FIELD4_NAME + ", " +
                    CMSConstants.ADDITIONAL_FIELD4_VALUE + ", " +
                    CMSConstants.ADDRESS_LINE1 + ", " +
                    CMSConstants.ADDRESS_LINE2 + ", " +
                    CMSConstants.ADDRESS_LINE3 + ", " +
                    CMSConstants.ADDRESS_LINE4 + ", " +
                    CMSConstants.ADDRESS_LINE5 + ", " +
                    CMSConstants.ADDRESS_POSTCODE + ", " +
                    CMSConstants.CONTACT_EMAIL + ", " +
                    CMSConstants.CONTACT_EMAIL_DISPLAY + ", " +
                    CMSConstants.CONTACT_EMAIL_SUBJECT + ", " +
                    CMSConstants.CONTACT_TEL + ", " +
                    CMSConstants.CONTACT_TEL_DISPLAY + ", " +
                    CMSConstants.CONTACT_WEB + ", " +
                    CMSConstants.CONTACT_WEB_DISPLAY + ", " +
                    CMSConstants.MODIFICATION_DATE + ", " +
                    CMSConstants.PAGE_HEADER +
                    " ) VALUES ( " +
                    "?,?,?,?,?,?,?,?,?,?," +
                    "?,?,?,?,?,?,?,?,?,?," +
                    "?,?,?,?,?,?,?,?,?,?," +
                    "?,?,?,?,?,?,?,?,?,?," +
                    "?,?,? );", bindArgs);

我不明白问题出在哪里。我查看了代码,“(”。

附近没有问题

希望有人可以帮助我。

感谢名单 newone

编辑: 这是我的新查询

this.db.execSQL("UPDATE " + CMSConstants.ITEMS + " SET " +
                CMSConstants.ID + "= ?, " +
                CMSConstants.TITLE + " = ?, " +
                CMSConstants.IS_PAGE + " = ?, " +
                CMSConstants.IS_HIDDEN + " = ?, " +
                CMSConstants.ITEM_TYPE + " = ?, " +
                CMSConstants.ORDER_INDEX + " = ?, " +
                CMSConstants.SECTION_ID + " = ?, " +
                CMSConstants.TABLE_SECTION_NAME + " = ?, " +
                CMSConstants.TABLE_SECTION_ID + " = ?, " +
                CMSConstants.IMAGE1_FILE + " = ?, " +
                CMSConstants.IMAGE1_CAPTION + " = ?, " +
                CMSConstants.IMAGE1_DISPLAY_IN_GALLERY + " = ?, " +
                CMSConstants.CATEGORY1 + " = ?, " +
                CMSConstants.CATEGORY2 + " = ?, " +
                CMSConstants.GEO_LONGITUDE + " = ?, " +
                CMSConstants.GEO_LATITUDE + " = ?, " +
                CMSConstants.DESCRIPTION + " = ?, " +
                CMSConstants.KEYWORDS + " = ?, " +
                CMSConstants.BLOCKWORDS + " = ?, " +
                CMSConstants.CLEAN_NAME + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD1_NAME + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD1_VALUE + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD2_NAME + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD2_VALUE + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD3_NAME + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD3_VALUE + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD4_NAME + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD4_VALUE + " = ?, " +
                CMSConstants.ADDRESS_LINE1 + " = ?, " +
                CMSConstants.ADDRESS_LINE2 + " = ?, " +
                CMSConstants.ADDRESS_LINE3 + " = ?, " +
                CMSConstants.ADDRESS_LINE4 + " = ?, " +
                CMSConstants.ADDRESS_LINE5 + " = ?, " +
                CMSConstants.ADDRESS_POSTCODE + " = ?, " +
                CMSConstants.CONTACT_EMAIL + " = ?, " +
                CMSConstants.CONTACT_EMAIL_DISPLAY + " = ?, " +
                CMSConstants.CONTACT_EMAIL_SUBJECT + " = ?, " +
                CMSConstants.CONTACT_TEL + " = ?, " +
                CMSConstants.CONTACT_TEL_DISPLAY + " = ?, " +
                CMSConstants.CONTACT_WEB + " = ?, " +
                CMSConstants.CONTACT_WEB_DISPLAY + " = ?, " +
                CMSConstants.MODIFICATION_DATE + " = ?, " +
                CMSConstants.PAGE_HEADER + " = ?"
                , bindArgs);

这是新错误:

09-27 09:39:03.105: WARN/System.err(8903): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
09-27 09:39:03.105: WARN/System.err(8903):     at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
09-27 09:39:03.115: WARN/System.err(8903):     at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61)
09-27 09:39:03.115: WARN/System.err(8903):     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1809)
09-27 09:39:03.115: WARN/System.err(8903):     at  de.enough.appmate.dbase.CMSResource.updateItem(CMSResource.java:1221)
09-27 09:39:03.115: WARN/System.err(8903):     at de.enough.appmate.dbase.CMSResourceUpdater.updateItems(CMSResourceUpdater.java:178)
09-27 09:39:03.115: WARN/System.err(8903):     at de.enough.appmate.dbase.CMSResourceUpdater.loadUpdates(CMSResourceUpdater.java:102)
09-27 09:39:03.115: WARN/System.err(8903):     at de.enough.appmate.dbase.CMSResourceUpdaterRunnable.run(CMSResourceUpdaterRunnable.java:32)
09-27 09:39:03.115: WARN/System.err(8903):     at java.lang.Thread.run(Thread.java:1019)

1 个答案:

答案 0 :(得分:2)

试试这个

this.db.execSQL("UPDATE " + CMSConstants.ITEMS + " SET "+CMSConstants.ID+"="+value)

我认为你的查询错了..

简单更新查询

"UPDATE TABLE_NAME SET COLUMN_NAME=COLUMN_VALUE"