当前位置: 首页>>代码示例>>Java>>正文


Java SQLiteStatement.execute方法代码示例

本文整理汇总了Java中net.sqlcipher.database.SQLiteStatement.execute方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteStatement.execute方法的具体用法?Java SQLiteStatement.execute怎么用?Java SQLiteStatement.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sqlcipher.database.SQLiteStatement的用法示例。


在下文中一共展示了SQLiteStatement.execute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
@Override
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
    SQLiteStatement statement = null;
    try {
        statement = connection.getDatabase().compileStatement(sql);
        if (autoGeneratedKeys == RETURN_GENERATED_KEYS) {
            long rowId = statement.executeInsert();
            insertResult = new SingleResultSet(this, rowId);
            return true;
        } else {
            statement.execute();
        }
    } catch (SQLiteException e) {
        SqlCipherConnection.throwSQLException(e);
    } finally {
        if (statement != null) {
            statement.close();
        }
    }
    return false;
}
 
开发者ID:requery,项目名称:requery,代码行数:22,代码来源:SqlCipherStatement.java

示例2: updateHasPhoneNumber

import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
/**
 * Updates the {@link RawContacts#HAS_PHONE_NUMBER} flag for the aggregate contact containing the
 * specified raw contact.
 */
public void updateHasPhoneNumber(SQLiteDatabase db, long rawContactId) {

    final SQLiteStatement hasPhoneNumberUpdate = db.compileStatement(
            "UPDATE " + Tables.RAW_CONTACTS +
            " SET " + RawContacts.HAS_PHONE_NUMBER + "="
                    + "(SELECT (CASE WHEN COUNT(*)=0 THEN 0 ELSE 1 END)"
                    + " FROM " + Tables.DATA_JOIN_RAW_CONTACTS
                    + " WHERE " + DataColumns.MIMETYPE_ID + "=?"
                            + " AND " + Phone.NUMBER + " NOT NULL)" +
            " WHERE " + RawContacts._ID + "=?");
    try {
        hasPhoneNumberUpdate.bindLong(1, mDbHelper.getMimeTypeId(Phone.CONTENT_ITEM_TYPE));
        hasPhoneNumberUpdate.bindLong(2, rawContactId);
        hasPhoneNumberUpdate.execute();
    } finally {
        hasPhoneNumberUpdate.close();
    }
}
 
开发者ID:SilentCircle,项目名称:silent-contacts-android,代码行数:23,代码来源:SimpleRawContactAggregator.java

示例3: bulkKeyStore

import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
private void bulkKeyStore(int c, String dbid, String values[]) {
    if(database !=null && database.isOpen()) {
        SQLiteStatement statement =
                database.compileStatement("INSERT INTO " +
                        TABLE_KEYS + " VALUES (null, ?, ?, ?, ?);");

        database.beginTransaction();

        while (c < (values.length - 1)) {
            statement.clearBindings();
            statement.bindString(1, values[c]);
            statement.bindString(2, dbid);
            statement.bindString(3, values[c + 1]);
            statement.bindString(4, values[c + 2]);
            statement.execute();
            c = c + 3;
        }

        database.setTransactionSuccessful();
        database.endTransaction();


        //disable adding contact if over
        Cursor contactCount = database.rawQuery("SELECT * FROM " + TABLE_CONTACTS, null);
        int max_contacts = context.getResources().getInteger(R.integer.config_max_contacts);

        if (contactCount.getCount() >= max_contacts) {
            prefs.edit().putBoolean(CONST.PREFS_CONTACTADD, false).apply();
        }
        contactCount.close();
    }
}
 
开发者ID:gtom1984,项目名称:Eulen,代码行数:33,代码来源:EulenDatabase.java

示例4: executeInsertInTx

import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
private void executeInsertInTx(SQLiteStatement stmt, Iterable<T> entities, boolean setPrimaryKey) {
    db.beginTransaction();
    try {
        synchronized (stmt) {
            if (identityScope != null) {
                identityScope.lock();
            }
            try {
                for (T entity : entities) {
                    bindValues(stmt, entity);
                    if (setPrimaryKey) {
                        long rowId = stmt.executeInsert();
                        updateKeyAfterInsertAndAttach(entity, rowId, false);
                    } else {
                        stmt.execute();
                    }
                }
            } finally {
                if (identityScope != null) {
                    identityScope.unlock();
                }
            }
        }
        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
    }
}
 
开发者ID:itsmechlark,项目名称:greendao-cipher,代码行数:29,代码来源:AbstractDao.java

示例5: deleteByKeyInsideSynchronized

import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
private void deleteByKeyInsideSynchronized(K key, SQLiteStatement stmt) {
    if (key instanceof Long) {
        stmt.bindLong(1, (Long) key);
    } else if (key == null) {
        throw new DaoException("Cannot delete entity, key is null");
    } else {
        stmt.bindString(1, key.toString());
    }
    stmt.execute();
}
 
开发者ID:itsmechlark,项目名称:greendao-cipher,代码行数:11,代码来源:AbstractDao.java

示例6: updateInsideSynchronized

import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
protected void updateInsideSynchronized(T entity, SQLiteStatement stmt, boolean lock) {
    // To do? Check if it's worth not to bind PKs here (performance).
    bindValues(stmt, entity);
    int index = config.allColumns.length + 1;
    K key = getKey(entity);
    if (key instanceof Long) {
        stmt.bindLong(index, (Long) key);
    } else if (key == null) {
        throw new DaoException("Cannot update entity without key - was it inserted before?");
    } else {
        stmt.bindString(index, key.toString());
    }
    stmt.execute();
    attachEntity(key, entity, lock);
}
 
开发者ID:itsmechlark,项目名称:greendao-cipher,代码行数:16,代码来源:AbstractDao.java


注:本文中的net.sqlcipher.database.SQLiteStatement.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。