Package com.atlassian.bamboo.utils.db
Class JdbcUtils
java.lang.Object
com.atlassian.bamboo.utils.db.JdbcUtils
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
execute
(Connection connection, String queryToFormat, String... args) Executes query on a connection.static <T> List<T>
executeQuery
(Connection connection, Function<ResultSet, T> function, String queryToFormat, String... args) Executes query on a connection.static boolean
executeQuietly
(Statement statement, String query) static String
executeSingleValueQuery
(Connection connection, String sql, String... args) getAllRows
(ResultSet rs) getAllRows
(ResultSet rs, Predicate<List<String>> filter) getColumnValue
(int columnIndex) Note that the columnIndex is 1-based, not 0-based.getListOfLong
(@NotNull Connection c, @NotNull String query) static long
getRowData
(ResultSet rs) getString
(int columnIndex) static String
static boolean
isTablePresent
(@NotNull Connection connection, @NotNull String tableName) static <T> List<T>
static int
runDeleteQuery
(@NotNull Connection connection, @NotNull String query, @NotNull String entityName) static int
runDeleteQuery
(@NotNull Connection connection, @NotNull String tableName, @NotNull String idColumn, @NotNull Iterable<? extends BambooIdProvider> objects) static int
runDeleteQuery
(@NotNull PreparedStatement statement, @NotNull String query, @NotNull String entityName) static int
runUpdateQuery
(@NotNull PreparedStatement statement, @NotNull String query, @NotNull String entityName)
-
Field Details
-
LOG_RESULT
-
-
Method Details
-
executeQuietly
-
execute
public static void execute(Connection connection, String queryToFormat, String... args) throws SQLException Executes query on a connection. Args are treated as a format string arguments for the query.- Throws:
SQLException
-
executeSingleValueQuery
public static String executeSingleValueQuery(Connection connection, String sql, String... args) throws SQLException - Throws:
SQLException
-
executeQuery
public static <T> List<T> executeQuery(Connection connection, Function<ResultSet, T> function, String queryToFormat, String... args) throws SQLExceptionExecutes query on a connection. Args are treated as a format string arguments for the query.- Throws:
SQLException
-
isTablePresent
public static boolean isTablePresent(@NotNull @NotNull Connection connection, @NotNull @NotNull String tableName) -
runDeleteQuery
public static int runDeleteQuery(@NotNull @NotNull Connection connection, @NotNull @NotNull String query, @NotNull @NotNull String entityName) throws SQLException - Throws:
SQLException
-
runDeleteQuery
public static int runDeleteQuery(@NotNull @NotNull PreparedStatement statement, @NotNull @NotNull String query, @NotNull @NotNull String entityName) - Parameters:
statement
- statement to be executed (caller is responsible for closing statement)query
-entityName
-- Returns:
- Throws:
SQLException
-
runUpdateQuery
public static int runUpdateQuery(@NotNull @NotNull PreparedStatement statement, @NotNull @NotNull String query, @NotNull @NotNull String entityName) throws SQLException - Parameters:
statement
- statement to be executed (caller is responsible for closing statement)query
-entityName
-- Returns:
- Throws:
SQLException
-
getListOfLong
@NotNull public static @NotNull List<Long> getListOfLong(@NotNull @NotNull Connection c, @NotNull @NotNull String query) throws SQLException - Throws:
SQLException
-
map
public static <T> List<T> map(ResultSet resultSet, Function<ResultSet, T> function) throws SQLException- Throws:
SQLException
-
runDeleteQuery
public static int runDeleteQuery(@NotNull @NotNull Connection connection, @NotNull @NotNull String tableName, @NotNull @NotNull String idColumn, @NotNull @NotNull Iterable<? extends BambooIdProvider> objects) throws SQLException - Throws:
SQLException
-
getColumnValue
Note that the columnIndex is 1-based, not 0-based. -
getRowData
- Throws:
SQLException
-
getAllRows
-
getAllRows
-
getString
-
getLong
-
getString
-