Package io.github.mfvanek.pg.utils
Class QueryExecutors
java.lang.Object
io.github.mfvanek.pg.utils.QueryExecutors
Utility class for executing SQL queries with various context parameters.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>executeQuery(io.github.mfvanek.pg.connection.PgConnection pgConnection, String sqlQuery, ResultSetExtractor<T> rse) Executes a given SQL query and extracts results using the providedResultSetExtractor.static <T> List<T>executeQueryWithBloatThreshold(io.github.mfvanek.pg.connection.PgConnection pgConnection, io.github.mfvanek.pg.model.PgContext pgContext, String sqlQuery, ResultSetExtractor<T> rse) Executes a given SQL query within the context of the provided schema name and bloat threshold.static <T> List<T>executeQueryWithRemainingPercentageThreshold(io.github.mfvanek.pg.connection.PgConnection pgConnection, io.github.mfvanek.pg.model.PgContext pgContext, String sqlQuery, ResultSetExtractor<T> rse) Executes a given SQL query within the context of the provided schema name and remaining percentage threshold.static <T> List<T>executeQueryWithSchema(io.github.mfvanek.pg.connection.PgConnection pgConnection, io.github.mfvanek.pg.model.PgContext pgContext, String sqlQuery, ResultSetExtractor<T> rse) Executes a given SQL query within the context of the provided schema name.
-
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 providedResultSetExtractor.- Type Parameters:
T- the type of the result- Parameters:
pgConnection- the PostgreSQL connection, cannot be nullsqlQuery- the SQL query to execute, cannot be nullrse- the result set extractor to process theResultSet, cannot be null- Returns:
- a list of results extracted by the
ResultSetExtractor - Throws:
NullPointerException- if any of the parameters are nullio.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 nullpgContext- the context containing the schema name, cannot be nullsqlQuery- the SQL query to execute, cannot be nullrse- the result set extractor to process theResultSet, cannot be null- Returns:
- a list of results extracted by the
ResultSetExtractor - Throws:
NullPointerException- if any of the parameters are nullio.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 nullpgContext- the context containing the schema name and bloat threshold, cannot be nullsqlQuery- the SQL query to execute, cannot be nullrse- the result set extractor to process theResultSet, cannot be null- Returns:
- a list of results extracted by the
ResultSetExtractor - Throws:
NullPointerException- if any of the parameters are nullio.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 nullpgContext- the context containing the schema name and remaining percentage threshold, cannot be nullsqlQuery- the SQL query to execute, cannot be nullrse- the result set extractor to process theResultSet, cannot be null- Returns:
- a list of results extracted by the
ResultSetExtractor - Throws:
NullPointerException- if any of the parameters are nullio.github.mfvanek.pg.connection.PgSqlException- if a database access error occurs
-