public long queryForLong ( DatabaseConnection databaseConnection , PreparedStmt < T > preparedStmt ) throws SQLException { CompiledStatement compiledStatement = preparedStmt . compile ( databaseConnection , StatementType . SELECT_LONG ) ; DatabaseResults results = null ; try { results = compiledStatement . runQuery ( null ) ; if ( results . first ( ) ) { return results . getLong ( 0 ) ; } else { throw new SQLException ( "No result found in queryForLong: " + preparedStmt . getStatement ( ) ) ; } } finally { IOUtils . closeThrowSqlException ( results , "results" ) ; IOUtils . closeThrowSqlException ( compiledStatement , "compiled statement" ) ; } }
Return a long value from a prepared query .