/** * Returns the long value of the first field selected given a query. If no rows are returned, * will throw SQLException. * <p> * If the value of the first field is null then 0 will be returned in prod, but an assert will * be thrown in test. */ long selectLong(Connection c, String key, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return basicSql.selectLongInternal(c, SQLString.getByKey(key, c), vs, null, true); }
/** * Returns the long value of the first field selected given a query. If no rows are returned, * will throw SQLException. * <p> * If the value of the first field is null then 0 will be returned in prod, but an assert will * be thrown in test. */ long selectLong(Connection c, RegisteredSQLString sql, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return selectLong(c, sql.getKey(), vs); }
@Override public int selectInteger(RegisteredSQLString sql, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return sqlConnectionHelper.selectInteger(c, sql.getKey(), vs); }
private void executeSqlQuery(BasicSQL basicSql) throws SQLException { Connection conn = createMockConnection(); basicSql.execute( conn, SQLString.getUnregisteredQuery("SELECT 1 FROM a.b;"), new Object[0], BasicSQL.AutoClose.FALSE); }
/** * Returns the integer value of the first field selected given a query. If no rows are returned, * will throw SQLException. * <p> * If the first field is null, then 0 will be returned. */ int selectIntegerUnregisteredQuery(Connection c, String sql, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return basicSql.selectIntegerInternal(c, SQLString.getUnregisteredQuery(sql), vs); }
boolean updateUnregisteredQuery(Connection c, String sql, Object... vs) throws PalantirSqlException { basicSql.updateInternal(c, SQLString.getUnregisteredQuery(sql), vs, AutoClose.TRUE); return true; }
/** * Returns the long value of the first field selected given a query. If no rows are returned, * will throw SQLException. * <p> * If the value of the first field is null then 0 will be returned in prod, but an assert will * be thrown in test. */ long selectLongUnregisteredQuery(Connection c, String sql, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return basicSql.selectLongInternal(c, SQLString.getUnregisteredQuery(sql), vs, null, true); }
/** * Returns true if at least one row comes back for the provided Otherwise, returns false. * * @param c * @param sql * @param vs * @return * @throws PalantirSqlException */ boolean selectExistsUnregisteredQuery(Connection c, String sql, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return basicSql.selectExistsInternal(c, SQLString.getUnregisteredQuery(sql), vs); }
@Override public boolean insertMany(RegisteredSQLString sql, Iterable<Object[]> list) throws PalantirSqlException { return sqlConnectionHelper.insertMany(c, sql.getKey(), list); }
@Override public AgnosticLightResultSet selectLightResultSet(RegisteredSQLString sql, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return sqlConnectionHelper.selectLightResultSet(c, sql.getKey(), vs); }
@Override public Long selectLongWithDefault(RegisteredSQLString sql, Long defaultVal, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return sqlConnectionHelper.selectLongWithDefault(c, sql.getKey(), defaultVal, vs); }
@Override public AgnosticResultSet selectResultSet(RegisteredSQLString sql, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return sqlConnectionHelper.selectResultSet(c, sql.getKey(), vs); }
@Override public boolean selectExists(RegisteredSQLString sql, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return sqlConnectionHelper.selectExists(c, sql.getKey(), vs); }
@Override public void updateMany(RegisteredSQLString sql, Iterable<Object[]> list) throws PalantirSqlException { sqlConnectionHelper.updateMany(c, sql.getKey(), list); }
@Override public int updateCountRows(RegisteredSQLString sql, Object... vs) throws PalantirSqlException { return sqlConnectionHelper.updateCountRows(c, sql.getKey(), vs); }
/** * Returns the long value of the first field selected given a query If no rows are returned, * will return defaultVal. * <p> * If the value of the first field is null, then defaultVal will be returned. This means that if * defaultVal is non-null, then this method won't return null. */ Long selectLongWithDefault(Connection c, String key, Long defaultVal, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return basicSql.selectLongInternal(c, SQLString.getByKey(key, c), vs, defaultVal, false); }
@Override public long selectLong(RegisteredSQLString sql, Object... vs) throws PalantirSqlException, PalantirInterruptedException { return sqlConnectionHelper.selectLong(c, sql.getKey(), vs); }
boolean insertMany(Connection c, RegisteredSQLString sql, Iterable<Object[]> list) throws PalantirSqlException { return insertMany(c, sql.getKey(), list); } }