use of net.sqlcipher.database.SQLiteException in project requery by requery.
the class SqlCipherMetaData method queryMemory.
@Override
protected <R> R queryMemory(Function<Cursor, R> function, String query) throws SQLException {
try {
final SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(":memory:", "", null);
Cursor cursor = database.rawQuery(query, null);
return function.apply(closeWithCursor(new Closeable() {
@Override
public void close() throws IOException {
database.close();
}
}, cursor));
} catch (SQLiteException e) {
throw new SQLException(e);
}
}
use of net.sqlcipher.database.SQLiteException in project requery by requery.
the class SqlCipherPreparedStatement method executeUpdate.
@Override
public int executeUpdate() throws SQLException {
if (autoGeneratedKeys == RETURN_GENERATED_KEYS) {
try {
long rowId = statement.executeInsert();
insertResult = new SingleResultSet(this, rowId);
updateCount = 1;
} catch (SQLiteException e) {
SqlCipherConnection.throwSQLException(e);
}
} else {
try {
updateCount = statement.executeUpdateDelete();
} catch (SQLiteException e) {
SqlCipherConnection.throwSQLException(e);
}
}
return updateCount;
}
use of net.sqlcipher.database.SQLiteException in project requery by requery.
the class SqlCipherStatement method execute.
@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;
}
use of net.sqlcipher.database.SQLiteException in project requery by requery.
the class SqlCipherPreparedStatement method executeQuery.
@Override
public ResultSet executeQuery() throws SQLException {
try {
String[] args = bindingsToArray();
cursor = connection.getDatabase().rawQuery(getSql(), args);
return queryResult = new CursorResultSet(this, cursor, false);
} catch (SQLiteException e) {
SqlCipherConnection.throwSQLException(e);
}
return null;
}
use of net.sqlcipher.database.SQLiteException in project requery by requery.
the class SqlCipherStatement method executeUpdate.
@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;
}
Aggregations