public class RDBJDBCTools extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
RDBJDBCTools.PreparedStatementComponent
Provides a component for a
PreparedStatement and a method for
setting the parameters within this component |
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_IN_CLAUSE |
| Constructor and Description |
|---|
RDBJDBCTools() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
appendInCondition(StringBuilder builder,
String field,
int placeholdersCount,
int maxListLength)
Appends following SQL condition to the builder:
ID in (?,?,?). |
static DocumentStoreException |
asDocumentStoreException(@NotNull Exception cause,
@NotNull String message) |
protected static ResultSet |
closeResultSet(@Nullable ResultSet rs)
Closes a
ResultSet, logging potential problems. |
protected static <T extends Statement> |
closeStatement(T stmt)
Closes a
Statement, logging potential problems. |
static RDBJDBCTools.PreparedStatementComponent |
createInStatement(String fieldName,
Collection<String> values,
boolean binary) |
protected static @NotNull String |
createTableName(@NotNull String prefix,
@NotNull String basename)
Creates a table name based on an optional prefix and a base name.
|
protected static String |
driverForDBType(String type) |
protected static String |
dumpResultSetMeta(ResultSetMetaData met)
Return approximated string representation of table DDL.
|
protected static @NotNull String |
getAdditionalMessages(SQLException ex)
Return a string containing additional messages from chained exceptions.
|
protected static @NotNull String |
isolationLevelToString(int isolationLevel)
Return string representation of transaction isolation level.
|
protected static String |
jdbctype(String jdbcurl) |
protected static boolean |
matchesSQLState(SQLException ex,
String... statePrefix)
Check whether the exception matches one of the given states.
|
protected static String |
versionCheck(DatabaseMetaData md,
int dbmax,
int dbmin,
int drmax,
int drmin,
String dbname)
Generate database + driver version diagnostics.
|
protected static String |
versionCheck(DatabaseMetaData md,
int dbmax,
int dbmin,
String dbname)
Generate database version diagnostics.
|
@NotNull protected static @NotNull String createTableName(@NotNull @NotNull String prefix, @NotNull @NotNull String basename) throws IllegalArgumentException
IllegalArgumentException - upon illegal characters in name@NotNull protected static @NotNull String isolationLevelToString(int isolationLevel)
protected static String dumpResultSetMeta(ResultSetMetaData met)
@NotNull protected static @NotNull String getAdditionalMessages(SQLException ex)
protected static boolean matchesSQLState(SQLException ex, String... statePrefix)
protected static String versionCheck(DatabaseMetaData md, int dbmax, int dbmin, int drmax, int drmin, String dbname) throws SQLException
md - metadata objectdbmax - minimal DB major version number (where -1 disables the
check)dbmin - minimal DB minor version numberdrmax - minimal driver major version number (where -1 disables
the check)drmin - minimal driver minor version numberdbname - database typeSQLExceptionprotected static String versionCheck(DatabaseMetaData md, int dbmax, int dbmin, String dbname) throws SQLException
md - metadata objectdbmax - minimal DB major version number (where -1 disables the
check)dbmin - minimal DB minor version numberdbname - database typeSQLExceptionprotected static <T extends Statement> T closeStatement(@Nullable T stmt)
Statement, logging potential problems.protected static ResultSet closeResultSet(@Nullable @Nullable ResultSet rs)
ResultSet, logging potential problems.protected static void appendInCondition(StringBuilder builder, String field, int placeholdersCount, int maxListLength)
ID in (?,?,?).
The field name ID and the number of place holders is
configurable. If the number of place holders is greater than
maxListLength, then the condition will have following form:
(ID in (?,?,?) or ID in (?,?,?) or ID in (?,?))builder - the condition will be appended herefield - name of the fieldplaceholdersCount - how many ? should be includedmaxListLength - what's the max number of ? in one listpublic static RDBJDBCTools.PreparedStatementComponent createInStatement(String fieldName, Collection<String> values, boolean binary)
public static DocumentStoreException asDocumentStoreException(@NotNull @NotNull Exception cause, @NotNull @NotNull String message)
Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.