开发者

stupid error android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed

here is the error:

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

Here is the code:

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 + " = ?, " +
                CMS开发者_JAVA技巧Constants.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);

and the bindArgs:

String[] bindArgs = { 
                (String) item.get(CMSConstants.ID),
                (String) item.get(CMSConstants.TITLE),
                (String) item.get(CMSConstants.IS_PAGE),
                (String) item.get(CMSConstants.IS_HIDDEN),
                (String) item.get(CMSConstants.ITEM_TYPE),
                (String) item.get(CMSConstants.ORDER_INDEX),
                (String) item.get(CMSConstants.SECTION_ID),
                "",
                "",
                (String) item.get(CMSConstants.IMAGE1_FILE),
                (String) item.get(CMSConstants.IMAGE1_CAPTION),
                (String) item.get(CMSConstants.IMAGE1_DISPLAY_IN_GALLERY),
                (String) item.get(CMSConstants.CATEGORY1),
                (String) item.get(CMSConstants.CATEGORY2),
                (String) item.get(CMSConstants.GEO_LONGITUDE),
                (String) item.get(CMSConstants.GEO_LATITUDE),
                (String) item.get(CMSConstants.DESCRIPTION),
                (String) item.get(CMSConstants.KEYWORDS),
                (String) item.get(CMSConstants.BLOCKWORDS),
                (String) item.get(CMSConstants.CLEAN_NAME),
                (String) item.get(CMSConstants.ADDITIONAL_FIELD1_NAME),
                (String) item.get(CMSConstants.ADDITIONAL_FIELD1_VALUE),
                (String) item.get(CMSConstants.ADDITIONAL_FIELD2_NAME),
                (String) item.get(CMSConstants.ADDITIONAL_FIELD2_VALUE),
                (String) item.get(CMSConstants.ADDITIONAL_FIELD3_NAME),
                (String) item.get(CMSConstants.ADDITIONAL_FIELD3_VALUE),
                (String) item.get(CMSConstants.ADDITIONAL_FIELD4_NAME),
                (String) item.get(CMSConstants.ADDITIONAL_FIELD4_VALUE),
                (String) item.get(CMSConstants.ADDRESS_LINE1),
                (String) item.get(CMSConstants.ADDRESS_LINE2),
                (String) item.get(CMSConstants.ADDRESS_LINE3),
                (String) item.get(CMSConstants.ADDRESS_LINE4),
                (String) item.get(CMSConstants.ADDRESS_LINE5),
                (String) item.get(CMSConstants.ADDRESS_POSTCODE),
                (String) item.get(CMSConstants.CONTACT_EMAIL),
                (String) item.get(CMSConstants.CONTACT_EMAIL_DISPLAY),
                (String) item.get(CMSConstants.CONTACT_EMAIL_SUBJECT),
                (String) item.get(CMSConstants.CONTACT_TEL),
                (String) item.get(CMSConstants.CONTACT_TEL_DISPLAY),
                (String) item.get(CMSConstants.CONTACT_WEB),
                (String) item.get(CMSConstants.CONTACT_WEB_DISPLAY),
                (String) item.get(CMSConstants.MODIFICATION_DATE),
                (String) item.get(CMSConstants.PAGE_HEADER)
        };

So has anyone an idea why I get this failure?

thanx newone


you are missing WHERE clause, As when you update anything you must point where you want to update

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜