public class JdbcUtils extends Object
Modifier and Type | Field and Description |
---|---|
static Function<ResultSet,Void> |
LOG_RESULT |
Modifier and Type | Method and Description |
---|---|
static 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) |
static List<List<String>> |
getAllRows(ResultSet rs) |
static List<List<String>> |
getAllRows(ResultSet rs,
Predicate<List<String>> filter) |
static Function<ResultSet,String> |
getColumnValue(int columnIndex)
Note that the columnIndex is 1-based, not 0-based.
|
static List<Long> |
getListOfLong(Connection c,
String query) |
static long |
getLong(ResultSet resultSet,
int columnIndex) |
static List<String> |
getRowData(ResultSet rs) |
static Function<ResultSet,String> |
getString(int columnIndex) |
static String |
getString(ResultSet resultSet,
int columnIndex) |
static boolean |
isTablePresent(Connection connection,
String tableName) |
static <T> List<T> |
map(ResultSet resultSet,
Function<ResultSet,T> function) |
static int |
runDeleteQuery(Connection connection,
String query,
String entityName) |
static int |
runDeleteQuery(Connection connection,
String tableName,
String idColumn,
Iterable<? extends BambooIdProvider> objects) |
static int |
runDeleteQuery(PreparedStatement statement,
String query,
String entityName) |
static int |
runUpdateQuery(PreparedStatement statement,
String query,
String entityName) |
public static void execute(Connection connection, String queryToFormat, String... args) throws SQLException
SQLException
public static String executeSingleValueQuery(Connection connection, String sql, String... args) throws SQLException
SQLException
public static <T> List<T> executeQuery(Connection connection, Function<ResultSet,T> function, String queryToFormat, String... args) throws SQLException
SQLException
public static boolean isTablePresent(@NotNull Connection connection, @NotNull String tableName)
public static int runDeleteQuery(@NotNull Connection connection, @NotNull String query, @NotNull String entityName) throws SQLException
SQLException
public static int runDeleteQuery(@NotNull PreparedStatement statement, @NotNull String query, @NotNull String entityName)
statement
- statement to be executed (caller is responsible for closing statement)query
- entityName
- SQLException
public static int runUpdateQuery(@NotNull PreparedStatement statement, @NotNull String query, @NotNull String entityName) throws SQLException
statement
- statement to be executed (caller is responsible for closing statement)query
- entityName
- SQLException
@NotNull public static List<Long> getListOfLong(@NotNull Connection c, @NotNull String query) throws SQLException
SQLException
public static <T> List<T> map(ResultSet resultSet, Function<ResultSet,T> function) throws SQLException
SQLException
public static int runDeleteQuery(@NotNull Connection connection, @NotNull String tableName, @NotNull String idColumn, @NotNull Iterable<? extends BambooIdProvider> objects) throws SQLException
SQLException
public static Function<ResultSet,String> getColumnValue(int columnIndex)
public static List<String> getRowData(ResultSet rs) throws SQLException
SQLException
public static List<List<String>> getAllRows(ResultSet rs, Predicate<List<String>> filter)
public static long getLong(ResultSet resultSet, int columnIndex)
Copyright © 2017 Atlassian Software Systems Pty Ltd. All rights reserved.