@Override public void execute() { delegate.execute(); }
public void insertUser(){ SQLiteDatabase db = dbHelper.getWritableDatabase(); String delSql = "DELETE FROM ACCOUNTS"; SQLiteStatement delStmt = db.compileStatement(delSql); delStmt.execute(); String sql = "INSERT INTO ACCOUNTS (account_id,account_name,account_image) VALUES(?,?,?)"; SQLiteStatement insertStmt = db.compileStatement(sql); insertStmt.clearBindings(); insertStmt.bindString(1, Integer.toString(this.accId)); insertStmt.bindString(2,this.accName); insertStmt.bindBlob(3, this.accImage); insertStmt.executeInsert(); db.close(); }
String sql = "CREATE TABLE table_name (column_1 INTEGER PRIMARY KEY, column_2 TEXT)"; SQLiteStatement stmt = db.compileStatement(sql); stmt.execute();
updateKeyAfterInsertAndAttach(entity, rowId, false); } else { rawStmt.execute();
SQLiteDatabase db = dbHelper.getWritableDatabase(); SQLiteStatement stmt = db.compileStatement("SELECT * FROM Country WHERE code = ?"); stmt.bindString(1, "US"); stmt.execute();
final SQLiteDatabase db = mOpenHelper.getWritableDatabase(); final SQLiteStatement statement = db.compileStatement(INSERT_QUERY); db.beginTransaction(); try { for(MyBean bean : list){ statement.clearBindings(); statement.bindString(1, bean.getName()); // rest of bindings statement.execute(); //or executeInsert() if id is needed } db.setTransactionSuccessful(); } finally { db.endTransaction(); }
void put(String key, String value) { insertStatement.bindString(1, key); insertStatement.bindString(2, value); insertStatement.execute(); insertStatement.clearBindings(); workingStorage.put(key, value); }
private void delete(String id) { db.beginTransaction(); try { SQLiteStatement stmt = sqlHelper.getDeleteStatement(); stmt.clearBindings(); stmt.bindString(1, id); stmt.execute(); SQLiteStatement deleteTagsStmt = sqlHelper.getDeleteJobTagsStatement(); deleteTagsStmt.bindString(1, id); deleteTagsStmt.execute(); db.setTransactionSuccessful(); jobStorage.delete(id); } finally { db.endTransaction(); } }
@Override public void removeBucket(int recordBlockId) { synchronized (database) { Log.d(TAG, "Removing record block with id [" + recordBlockId + "] from storage"); if (deleteByBucketIdStatement == null) { try { deleteByBucketIdStatement = database.compileStatement( PersistentLogStorageConstants.KAA_DELETE_BY_BUCKET_ID); } catch (SQLiteException ex) { Log.e(TAG, "Can't create record block deletion statement", ex); throw new RuntimeException(ex); } } try { deleteByBucketIdStatement.bindLong(1, recordBlockId); deleteByBucketIdStatement.execute(); long removedRecordsCount = getAffectedRowCount(); if (removedRecordsCount > 0) { totalRecordCount -= removedRecordsCount; Log.i(TAG, "Removed " + removedRecordsCount + " records from storage. Total log record count: " + totalRecordCount); } else { Log.i(TAG, "No records were removed from storage"); } } catch (SQLiteException ex) { Log.e(TAG, "Failed to remove record block with id [" + recordBlockId + "]", ex); } } }
resetBucketIdStatement.execute();
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); }
private void updateStorageParams() { SQLiteStatement updateInfoStatement = null; try { updateInfoStatement = database.compileStatement( PersistentLogStorageConstants.KAA_UPDATE_STORAGE_INFO); updateInfoStatement.bindString(1, PersistentLogStorageConstants.STORAGE_BUCKET_SIZE); updateInfoStatement.bindLong(2, maxBucketSize); updateInfoStatement.execute(); updateInfoStatement.bindString(1, PersistentLogStorageConstants.STORAGE_RECORD_COUNT); updateInfoStatement.bindLong(2, maxRecordCount); updateInfoStatement.execute(); } catch (SQLiteException ex) { Log.e(TAG, "Can't prepare update storage info statement", ex); throw new RuntimeException("Can't prepare update storage info statement"); } finally { tryCloseStatement(updateInfoStatement); } }
private void updateBucketState(int bucketId) { synchronized (database) { Log.v(TAG, "Updating bucket id [" + bucketId + "]"); try { if (updateBucketStateStatement == null) { updateBucketStateStatement = database.compileStatement( PersistentLogStorageConstants.KAA_UPDATE_BUCKET_ID); } updateBucketStateStatement.bindString( 1, PersistentLogStorageConstants.BUCKET_STATE_COLUMN); updateBucketStateStatement.bindLong(2, bucketId); updateBucketStateStatement.execute(); long affectedRows = getAffectedRowCount(); if (affectedRows > 0) { Log.i(TAG, "Successfully updated state for bucket ID [" + bucketId + "] for log records: " + affectedRows); } else { Log.w(TAG, "No log records were updated"); } } catch (SQLiteException ex) { Log.e(TAG, "Failed to update state for bucket [" + bucketId + "]", ex); } } }
@Override public void onJobCancelled(JobHolder jobHolder) { SQLiteStatement stmt = sqlHelper.getMarkAsCancelledStatement(); stmt.clearBindings(); stmt.bindString(1, jobHolder.getId()); stmt.execute(); }
@Before public void setUp() throws Exception { final File databasePath = ApplicationProvider.getApplicationContext().getDatabasePath("path"); databasePath.getParentFile().mkdirs(); database = SQLiteDatabase.openOrCreateDatabase(databasePath.getPath(), null); SQLiteStatement createStatement = database.compileStatement("CREATE TABLE `routine` (`id` INTEGER PRIMARY KEY AUTOINCREMENT , `name` VARCHAR , `lastUsed` INTEGER DEFAULT 0 , UNIQUE (`name`)) ;"); createStatement.execute(); SQLiteStatement createStatement2 = database.compileStatement("CREATE TABLE `countme` (`id` INTEGER PRIMARY KEY AUTOINCREMENT , `name` VARCHAR , `lastUsed` INTEGER DEFAULT 0 , UNIQUE (`name`)) ;"); createStatement2.execute(); }
@Before public void setUp() throws Exception { database = createDatabase("database.db"); SQLiteStatement createStatement = database.compileStatement( "CREATE TABLE `routine` (`id` INTEGER PRIMARY KEY AUTOINCREMENT , `name` VARCHAR , `lastUsed` INTEGER DEFAULT 0 , UNIQUE (`name`)) ;"); createStatement.execute(); conn = getSQLiteConnection(database); }
@Override public void execute() { statement.execute(); }
/** * This method is called when a job is pulled to run. * It is properly marked so that it won't be returned from next job queries. * <p/> * Same mechanism is also used for cancelled jobs. * * @param jobHolder The job holder to update session id */ private void setSessionIdOnJob(JobHolder jobHolder) { SQLiteStatement stmt = sqlHelper.getOnJobFetchedForRunningStatement(); jobHolder.setRunCount(jobHolder.getRunCount() + 1); jobHolder.setRunningSessionId(sessionId); stmt.clearBindings(); stmt.bindLong(1, jobHolder.getRunCount()); stmt.bindLong(2, sessionId); stmt.bindString(3, jobHolder.getId()); stmt.execute(); }
statement.bindString(3, timeStamp); statement.bindLong(4, isPersistent ? 1 : 0); statement.execute(); return true; } catch (Exception e) {