本文整理汇总了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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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);
}