Java SQLITE更新或插入语句不';我不想执行 public synchronized void saveMatchValue(int-photoRecOwner, int[]photocassign,float[]value){ SQLiteDatabase=databaseHelper.getWritableDatabase(); database.beginTransaction(); 字符串sql=“UPDATE”+TypeContract.CTablePhotoMatch.TABLE\u名称 +“SET”+TypeContract.CTablePhotoMatch.VALUE+“=?” +“WHERE”+TypeContract.CTablePhotoMatch.FK_所有者 +“=”和“+TypeContract.CTablePhotoMatch.FK_ASSIGN+”=?;” +“插入或忽略到” +TypeContract.CTablePhotoMatch.TABLE_NAME+“(” +TypeContract.CTablePhotoMatch.FK_OWNER+“,” +TypeContract.CTablePhotoMatch.FK_ASSIGN+“,” +TypeContract.CTablePhotoMatch.VALUE+)值(?,?);”; SQLiteStatement stmt=database.compileStatement(sql); 试一试{ int行=photoCassign.length; 对于(int i=0;iPhotoCassign[i]){ stmt.bindLong(1,光共聚焦); //stmt.bindLong(索引,值) stmt.bindLong(2,photocassign[i]); }否则{ stmt.bindLong(1,photocassign[i]); stmt.bindLong(2,光共聚焦); } stmt.bindDouble(3,值[i]); stmt.execute(); stmt.clearBindings(); } database.setTransactionSuccessful(); }最后{ stmt.close(); //updtStmt.close(); 数据库。endTransaction(); //close()数据库; } }

Java SQLITE更新或插入语句不';我不想执行 public synchronized void saveMatchValue(int-photoRecOwner, int[]photocassign,float[]value){ SQLiteDatabase=databaseHelper.getWritableDatabase(); database.beginTransaction(); 字符串sql=“UPDATE”+TypeContract.CTablePhotoMatch.TABLE\u名称 +“SET”+TypeContract.CTablePhotoMatch.VALUE+“=?” +“WHERE”+TypeContract.CTablePhotoMatch.FK_所有者 +“=”和“+TypeContract.CTablePhotoMatch.FK_ASSIGN+”=?;” +“插入或忽略到” +TypeContract.CTablePhotoMatch.TABLE_NAME+“(” +TypeContract.CTablePhotoMatch.FK_OWNER+“,” +TypeContract.CTablePhotoMatch.FK_ASSIGN+“,” +TypeContract.CTablePhotoMatch.VALUE+)值(?,?);”; SQLiteStatement stmt=database.compileStatement(sql); 试一试{ int行=photoCassign.length; 对于(int i=0;iPhotoCassign[i]){ stmt.bindLong(1,光共聚焦); //stmt.bindLong(索引,值) stmt.bindLong(2,photocassign[i]); }否则{ stmt.bindLong(1,photocassign[i]); stmt.bindLong(2,光共聚焦); } stmt.bindDouble(3,值[i]); stmt.execute(); stmt.clearBindings(); } database.setTransactionSuccessful(); }最后{ stmt.close(); //updtStmt.close(); 数据库。endTransaction(); //close()数据库; } },java,sqlite,sql-update,Java,Sqlite,Sql Update,没有错误和编译错误 我不知道sql语句语法是否正确:具体化:,但如果没有编译错误,则不会执行insert和(可能是update)命令。。。。 我可以了解更多详细信息吗?(sqlite statemenst)要找出错误您只能使用sqlite语句执行单个语句。后面的SQL未执行 拆分SQL以分别执行语句。为什么要使用binddoull?是的,这是我最初的解决方案,但它非常简单。我需要一些快速的解决方案 public synchronized void saveMatchValue(int photo

没有错误和编译错误

我不知道sql语句语法是否正确:具体化:,但如果没有编译错误,则不会执行insert和(可能是update)命令。。。。
我可以了解更多详细信息吗?(sqlite statemenst)要找出错误

您只能使用
sqlite语句
执行单个语句。
后面的SQL未执行


拆分SQL以分别执行语句。

为什么要使用
binddoull
?是的,这是我最初的解决方案,但它非常简单。我需要一些快速的解决方案
public synchronized void saveMatchValue(int photoRecOwner,
        int[] photoRecAssign, float[] value) {
    SQLiteDatabase database = databaseHelper.getWritableDatabase();
    database.beginTransaction();
    String sql = " UPDATE " + TypeContract.CTablePhotoMatch.TABLE_NAME
            + " SET " + TypeContract.CTablePhotoMatch.VALUE + "=? "
            + " WHERE " + TypeContract.CTablePhotoMatch.FK_OWNER
            + "=? AND " + TypeContract.CTablePhotoMatch.FK_ASSIGN + "=? ;"
            + " INSERT OR IGNORE INTO "
            + TypeContract.CTablePhotoMatch.TABLE_NAME + "("
            + TypeContract.CTablePhotoMatch.FK_OWNER + ","
            + TypeContract.CTablePhotoMatch.FK_ASSIGN + ","
            + TypeContract.CTablePhotoMatch.VALUE + ") VALUES (?, ?, ?);";

    SQLiteStatement stmt = database.compileStatement(sql);

    try {

        int rows = photoRecAssign.length;
        for (int i = 0; i < rows; i++) {

            if (photoRecOwner > photoRecAssign[i]) {
                stmt.bindLong(1, photoRecOwner);
                // stmt.bindLong(index, value)
                stmt.bindLong(2, photoRecAssign[i]);

            } else {
                stmt.bindLong(1, photoRecAssign[i]);
                stmt.bindLong(2, photoRecOwner);

            }
            stmt.bindDouble(3, value[i]);

            stmt.execute();
            stmt.clearBindings();

        }
        database.setTransactionSuccessful();
    } finally {
        stmt.close();
        // updtStmt.close();
        database.endTransaction();
        // database.close();
    }
}