Search in sources :

Example 1 with SingleResultSet

use of io.requery.android.sqlite.SingleResultSet 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 SingleResultSet

use of io.requery.android.sqlite.SingleResultSet in project requery by requery.

the class SqlitexPreparedStatement 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) {
            SqlitexConnection.throwSQLException(e);
        }
    } else {
        try {
            updateCount = statement.executeUpdateDelete();
        } catch (SQLiteException e) {
            SqlitexConnection.throwSQLException(e);
        }
    }
    return updateCount;
}
Also used : SingleResultSet(io.requery.android.sqlite.SingleResultSet) SQLiteException(android.database.sqlite.SQLiteException)

Example 3 with SingleResultSet

use of io.requery.android.sqlite.SingleResultSet 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;
}
Also used : SingleResultSet(io.requery.android.sqlite.SingleResultSet) SQLiteException(net.sqlcipher.database.SQLiteException)

Example 4 with SingleResultSet

use of io.requery.android.sqlite.SingleResultSet 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;
}
Also used : SQLiteStatement(net.sqlcipher.database.SQLiteStatement) SingleResultSet(io.requery.android.sqlite.SingleResultSet) SQLiteException(net.sqlcipher.database.SQLiteException)

Example 5 with SingleResultSet

use of io.requery.android.sqlite.SingleResultSet 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

SingleResultSet (io.requery.android.sqlite.SingleResultSet)6 SQLiteException (android.database.sqlite.SQLiteException)3 SQLiteException (net.sqlcipher.database.SQLiteException)3 SQLiteStatement (io.requery.android.database.sqlite.SQLiteStatement)2 SQLiteStatement (net.sqlcipher.database.SQLiteStatement)2