@Override public long simpleQueryForLong() { return delegate.simpleQueryForLong(); }
String sql = "SELECT COUNT(*) FROM table_name"; SQLiteStatement statement = db.compileStatement(sql); long result = statement.simpleQueryForLong();
public int getMaxColumnData() { mDb = mDbManager.getReadableDatabase(); final SQLiteStatement stmt = mDb .compileStatement("SELECT MAX(column) FROM Table"); return (int) stmt.simpleQueryForLong(); }
SQLiteStatement s = mDb.compileStatement( "select count(*) from users where uname='" + loginname + "' and pwd='" + loginpass + "'; " ); long count = s.simpleQueryForLong();
@Override public int countReadyJobs(@NonNull Constraint constraint) { final Where where = createWhere(constraint); final long result = where.countReady(db, reusedStringBuilder).simpleQueryForLong(); return (int) result; }
/** * {@inheritDoc} */ @Override public Long getNextJobDelayUntilNs(@NonNull Constraint constraint) { final Where where = createWhere(constraint); try { long result = where.nextJobDelayUntil(db, sqlHelper).simpleQueryForLong(); return result == Params.FOREVER ? null : result; } catch (SQLiteDoneException empty) { return null; } }
return stmt.simpleQueryForLong(); } finally { stmt.close();
/** * {@inheritDoc} */ @Override public int count() { SQLiteStatement stmt = sqlHelper.getCountStatement(); stmt.clearBindings(); stmt.bindLong(1, sessionId); return (int) stmt.simpleQueryForLong(); }
@Test(expected = SQLiteDoneException.class) public void simpleQueryForLongThrowsSQLiteDoneExceptionTest() throws Exception { //throw SQLiteDOneException if no rows returned. SQLiteStatement stmt = database.compileStatement("SELECT * FROM `countme` where `name`= 'cessationoftime'"); stmt.simpleQueryForLong(); }
@Test public void simpleQueryTest() throws Exception { SQLiteStatement stmt = database.compileStatement("SELECT count(*) FROM `countme`"); assertThat(stmt.simpleQueryForLong()).isEqualTo(0L); assertThat(stmt.simpleQueryForString()).isEqualTo("0"); SQLiteStatement insertStatement = database.compileStatement("INSERT INTO `countme` (`name` ,`lastUsed` ) VALUES (?,?)"); insertStatement.bindString(1, "Leg Press"); insertStatement.bindLong(2, 0); insertStatement.executeInsert(); assertThat(stmt.simpleQueryForLong()).isEqualTo(1L); assertThat(stmt.simpleQueryForString()).isEqualTo("1"); insertStatement.bindString(1, "Bench Press"); insertStatement.bindLong(2, 1); insertStatement.executeInsert(); assertThat(stmt.simpleQueryForLong()).isEqualTo(2L); assertThat(stmt.simpleQueryForString()).isEqualTo("2"); }
@Override public long simpleQueryForLong() { return statement.simpleQueryForLong(); }
private static final String DB_TABLE_PLACES = "Places"; private SQLiteDatabase mDatabase; private long fetchPlacesCount() { String sql = "SELECT COUNT(*) FROM " + DB_TABLE_PLACES; SQLiteStatement statement = mDatabase.compileStatement(sql); long count = statement.simpleQueryForLong(); return count; }
@Override public long simpleQueryForLong(String sql, Object[] bindArgs) { SQLiteStatement statement = null; try { statement = db.compileStatement(sql); SquidCursorFactory.bindArgumentsToProgram(statement, bindArgs); return statement.simpleQueryForLong(); } finally { if (statement != null) { statement.close(); } } }
private long performGetLength() { SQLiteDatabase database = mDatabaseSupplier.getDatabase(); if (database == null) { return 0; } String sql = "SELECT count(" + WXSQLiteOpenHelper.COLUMN_KEY + ") FROM " + WXSQLiteOpenHelper.TABLE_STORAGE; SQLiteStatement statement = null; try { statement = database.compileStatement(sql); return statement.simpleQueryForLong(); } catch (Exception e) { WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute getLength:" + e.getMessage()); return 0; } finally { if(statement != null) { statement.close(); } } }
public int countjournals() { SQLiteStatement dbJournalCountQuery; dbJournalCountQuery = mDb.compileStatement("select count(*) from" + DATABASE_JOURNAL_TABLE); return (int) dbJournalCountQuery.simpleQueryForLong(); }
long sumValue = -1L; Database db = ((Application)SugarApp.getSugarContext()).obtainDatabase(); SQLiteDatabase sqLiteDatabase = db.getDB(); SQLiteStatement sqLiteStatement = sqLiteDatabase.compileStatement( "SELECT SUM(column_name) FROM table_name"); try { sumValue = sqLiteStatement.simpleQueryForLong(); } catch (Exception var16) { var16.printStackTrace(); } finally { sqLiteStatement.close(); }
public static long runQueryWithStrings(SQLiteDatabase db, String stmtStr, String ... str) { SQLiteStatement s = createOrGetStatement(db, stmtStr); for(int i = 0; i < str.length; i++) { s.bindString(i+1, str[i]); } return s.simpleQueryForLong(); }
long getCount() { String sql = "SELECT COUNT(*) FROM " + SearchSploit.TABLE; SQLiteDatabase db = this.getWritableDatabase(); SQLiteStatement statement = db.compileStatement(sql); long count = statement.simpleQueryForLong(); return count; }
public boolean someMethod(String s) { SQLiteDatabase db = getReadableDatabase(); String sql = "select count(*) from " + TABLE_NAME + " where " + COLUMN_WORD + " = " + DatabaseUtils.sqlEscapeString(s); SQLiteStatement statement = db.compileStatement(sql); try { return statement.simpleQueryForLong() > 0; } finally { statement.close(); } }
static public int getCount(Context context) { SQLiteStatement statement = getDb(context).compileStatement("SELECT COUNT(*) FROM " + TABLE_NAME); int result = (int) statement.simpleQueryForLong(); statement.close(); return result; }