Class QueryExecutors

java.lang.Object
io.github.mfvanek.pg.utils.QueryExecutors

public final class QueryExecutors extends Object
Utility class for executing SQL queries with various context parameters.
  • Method Details

    • executeQuery

      @Nonnull public static <T> List<T> executeQuery(@Nonnull io.github.mfvanek.pg.connection.PgConnection pgConnection, @Nonnull String sqlQuery, @Nonnull ResultSetExtractor<T> rse)
      Executes a given SQL query and extracts results using the provided ResultSetExtractor.
      Type Parameters:
      T - the type of the result
      Parameters:
      pgConnection - the PostgreSQL connection, cannot be null
      sqlQuery - the SQL query to execute, cannot be null
      rse - the result set extractor to process the ResultSet, cannot be null
      Returns:
      a list of results extracted by the ResultSetExtractor
      Throws:
      NullPointerException - if any of the parameters are null
      io.github.mfvanek.pg.connection.PgSqlException - if a database access error occurs
    • executeQueryWithSchema

      @Nonnull public static <T> List<T> executeQueryWithSchema(@Nonnull io.github.mfvanek.pg.connection.PgConnection pgConnection, @Nonnull io.github.mfvanek.pg.model.PgContext pgContext, @Nonnull String sqlQuery, @Nonnull ResultSetExtractor<T> rse)
      Executes a given SQL query within the context of the provided schema name.
      Type Parameters:
      T - the type of the result
      Parameters:
      pgConnection - the PostgreSQL connection, cannot be null
      pgContext - the context containing the schema name, cannot be null
      sqlQuery - the SQL query to execute, cannot be null
      rse - the result set extractor to process the ResultSet, cannot be null
      Returns:
      a list of results extracted by the ResultSetExtractor
      Throws:
      NullPointerException - if any of the parameters are null
      io.github.mfvanek.pg.connection.PgSqlException - if a database access error occurs
    • executeQueryWithBloatThreshold

      @Nonnull public static <T> List<T> executeQueryWithBloatThreshold(@Nonnull io.github.mfvanek.pg.connection.PgConnection pgConnection, @Nonnull io.github.mfvanek.pg.model.PgContext pgContext, @Nonnull String sqlQuery, @Nonnull ResultSetExtractor<T> rse)
      Executes a given SQL query within the context of the provided schema name and bloat threshold.
      Type Parameters:
      T - the type of the result
      Parameters:
      pgConnection - the PostgreSQL connection, cannot be null
      pgContext - the context containing the schema name and bloat threshold, cannot be null
      sqlQuery - the SQL query to execute, cannot be null
      rse - the result set extractor to process the ResultSet, cannot be null
      Returns:
      a list of results extracted by the ResultSetExtractor
      Throws:
      NullPointerException - if any of the parameters are null
      io.github.mfvanek.pg.connection.PgSqlException - if a database access error occurs
    • executeQueryWithRemainingPercentageThreshold

      @Nonnull public static <T> List<T> executeQueryWithRemainingPercentageThreshold(@Nonnull io.github.mfvanek.pg.connection.PgConnection pgConnection, @Nonnull io.github.mfvanek.pg.model.PgContext pgContext, @Nonnull String sqlQuery, @Nonnull ResultSetExtractor<T> rse)
      Executes a given SQL query within the context of the provided schema name and remaining percentage threshold.
      Type Parameters:
      T - the type of the result
      Parameters:
      pgConnection - the PostgreSQL connection, cannot be null
      pgContext - the context containing the schema name and remaining percentage threshold, cannot be null
      sqlQuery - the SQL query to execute, cannot be null
      rse - the result set extractor to process the ResultSet, cannot be null
      Returns:
      a list of results extracted by the ResultSetExtractor
      Throws:
      NullPointerException - if any of the parameters are null
      io.github.mfvanek.pg.connection.PgSqlException - if a database access error occurs