本文整理汇总了Java中net.sqlcipher.database.SQLiteStatement.close方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteStatement.close方法的具体用法?Java SQLiteStatement.close怎么用?Java SQLiteStatement.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sqlcipher.database.SQLiteStatement
的用法示例。
在下文中一共展示了SQLiteStatement.close方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: executeUpdate
import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
@Override
public int executeUpdate(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 1;
} else {
return updateCount = statement.executeUpdateDelete();
}
} catch (SQLiteException e) {
SqlCipherConnection.throwSQLException(e);
} finally {
if (statement != null) {
statement.close();
}
}
return 0;
}
示例3: 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();
}
}
示例4: insertNameLookup
import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
private void insertNameLookup(SQLiteDatabase db) {
db.execSQL("DELETE FROM " + Tables.NAME_LOOKUP);
SQLiteStatement nameLookupInsert = db.compileStatement(
"INSERT OR IGNORE INTO " + Tables.NAME_LOOKUP + "("
+ NameLookupColumns.RAW_CONTACT_ID + ","
+ NameLookupColumns.DATA_ID + ","
+ NameLookupColumns.NAME_TYPE + ","
+ NameLookupColumns.NORMALIZED_NAME +
") VALUES (?,?,?,?)");
try {
insertStructuredNameLookup(db, nameLookupInsert);
insertEmailLookup(db, nameLookupInsert);
// insertNicknameLookup(db, nameLookupInsert);
} finally {
nameLookupInsert.close();
}
}
示例5: lookupMimeTypeId
import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
private long lookupMimeTypeId(String mimetype, SQLiteDatabase db) {
final SQLiteStatement mimetypeQuery = db.compileStatement(
"SELECT " + MimetypesColumns._ID +
" FROM " + Tables.MIMETYPES +
" WHERE " + MimetypesColumns.MIMETYPE + "=?");
final SQLiteStatement mimetypeInsert = db.compileStatement(
"INSERT INTO " + Tables.MIMETYPES + "("
+ MimetypesColumns.MIMETYPE +
") VALUES (?)");
try {
return lookupAndCacheId(mimetypeQuery, mimetypeInsert, mimetype, mMimetypeCache);
} finally {
mimetypeQuery.close();
mimetypeInsert.close();
}
}
示例6: insert
import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
public int insert(String statement, Object[] args, FieldType[] argFieldTypes, GeneratedKeyHolder keyHolder)
throws SQLException {
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement(statement);
bindArgs(stmt, args, argFieldTypes);
long rowId = stmt.executeInsert();
if (keyHolder != null) {
keyHolder.addKey(rowId);
}
/*
* I've decided to not do the CHANGES() statement here like we do down below in UPDATE because we know that
* it worked (since it didn't throw) so we know that 1 is right.
*/
int result = 1;
logger.trace("{}: insert statement is compiled and executed, changed {}: {}", this, result, statement);
return result;
} catch (android.database.SQLException e) {
throw SqlExceptionUtil.create("inserting to database failed: " + statement, e);
} finally {
if (stmt != null) {
stmt.close();
}
}
}
示例7: getIndexSpanningIteratorOrNull
import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
protected SqlStorageIterator<T> getIndexSpanningIteratorOrNull(SQLiteDatabase db, boolean includeData) {
//If we're just iterating over ID's, we may want to use a different, much
//faster method depending on our stats. This method retrieves the
//index records that _don't_ exist so we can assume the spans that
//do.
if (!includeData && STORAGE_OPTIMIZATIONS_ACTIVE) {
SQLiteStatement min = db.compileStatement("SELECT MIN(" + DatabaseHelper.ID_COL + ") from " + table);
SQLiteStatement max = db.compileStatement("SELECT MAX(" + DatabaseHelper.ID_COL + ") from " + table);
SQLiteStatement count = db.compileStatement("SELECT COUNT(" + DatabaseHelper.ID_COL + ") from " + table);
int minValue = (int)min.simpleQueryForLong();
int maxValue = (int)max.simpleQueryForLong() + 1;
int countValue = (int)count.simpleQueryForLong();
min.close();
max.close();
count.close();
double density = countValue / (maxValue - minValue * 1.0);
//Ok, so basic metrics:
//1) Only use a covering iterator if the number of records is > 1k
//2) Only use a covering iterator if the number of records is less than 100k (vital, hard limit)
//3) Only use a covering iterator if the record density is 50% or more
if (countValue > 1000 &&
countValue < 100000 &&
density >= 0.5) {
return getCoveringIndexIterator(db, minValue, maxValue, countValue);
}
}
return null;
}
示例8: longForQuery
import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
/**
* Utility method to run the query on the db and return the value in the
* first column of the first row.
*/
public static long longForQuery(SQLiteDatabase db, String query) {
SQLiteStatement prog = db.compileStatement(query);
try {
return prog.simpleQueryForLong();
} finally {
prog.close();
}
}
示例9: longForQuery
import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
/**
* Utility method to run the query on the db and return the value in the
* first column of the first row.
*/
public static long longForQuery(SQLiteDatabase db, String query, String[] selectionArgs) {
SQLiteStatement prog = db.compileStatement(query);
try {
return longForQuery(prog, selectionArgs);
} finally {
prog.close();
}
}
示例10: stringForQuery
import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
/**
* Utility method to run the query on the db and return the value in the
* first column of the first row.
*/
public static String stringForQuery(SQLiteDatabase db, String query, String[] selectionArgs) {
SQLiteStatement prog = db.compileStatement(query);
try {
return stringForQuery(prog, selectionArgs);
} finally {
prog.close();
}
}
示例11: queryForLong
import net.sqlcipher.database.SQLiteStatement; //导入方法依赖的package包/类
public long queryForLong(String statement) throws SQLException {
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement(statement);
long result = stmt.simpleQueryForLong();
logger.trace("{}: query for long simple query returned {}: {}", this, result, statement);
return result;
} catch (android.database.SQLException e) {
throw SqlExceptionUtil.create("queryForLong from database failed: " + statement, e);
} finally {
if (stmt != null) {
stmt.close();
}
}
}