Search in sources :

Example 1 with SQLiteStatement

use of io.requery.android.database.sqlite.SQLiteStatement in project requery by requery.

the class SqlitexStatement 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) {
        SqlitexConnection.throwSQLException(e);
    } finally {
        if (statement != null) {
            statement.close();
        }
    }
    return false;
}
Also used : SQLiteStatement(io.requery.android.database.sqlite.SQLiteStatement) SingleResultSet(io.requery.android.sqlite.SingleResultSet) SQLiteException(android.database.sqlite.SQLiteException)

Example 2 with SQLiteStatement

use of io.requery.android.database.sqlite.SQLiteStatement in project requery by requery.

the class SqlitexStatement 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);
            updateCount = 1;
        } else {
            updateCount = statement.executeUpdateDelete();
        }
    } catch (SQLiteException e) {
        SqlitexConnection.throwSQLException(e);
    } finally {
        if (statement != null) {
            statement.close();
        }
    }
    return updateCount;
}
Also used : SQLiteStatement(io.requery.android.database.sqlite.SQLiteStatement) SingleResultSet(io.requery.android.sqlite.SingleResultSet) SQLiteException(android.database.sqlite.SQLiteException)

Aggregations

SQLiteException (android.database.sqlite.SQLiteException)2 SQLiteStatement (io.requery.android.database.sqlite.SQLiteStatement)2 SingleResultSet (io.requery.android.sqlite.SingleResultSet)2