public final class DBUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CONNECTION_ARGUMENTS |
static String |
FETCH_SIZE |
static String |
OVERRIDE_SCHEMA |
static String |
PATTERN_TO_REPLACE |
static String |
REPLACE_WITH |
| Modifier and Type | Method and Description |
|---|---|
static void |
cleanup(Class<? extends Driver> driverClass)
Performs any Database related cleanup
|
static void |
deregisterAllDrivers(Class<? extends Driver> driverClass)
De-register all SQL drivers that are associated with the class
|
static DriverCleanup |
ensureJDBCDriverIsAvailable(Class<? extends Driver> jdbcDriverClass,
String connectionString,
String jdbcPluginType,
String jdbcPluginName)
Ensures that the JDBC Driver specified in configuration is available and can be loaded.
|
static List<io.cdap.cdap.api.data.schema.Schema.Field> |
getOriginalSchema(ResultSet resultSet)
Given the result set, get the metadata of the result set and return
list of
Schema.Field,
where name of the field is same as column name and type of the field is obtained using
DBUtils#getSchema(int, int, int) |
static List<io.cdap.cdap.api.data.schema.Schema.Field> |
getSchemaFields(ResultSet resultSet,
String patternToReplace,
String replaceWith)
Given the result set, get the metadata of the result set and return
list of
Schema.Field,
where name of the field is same as column name and type of the field is obtained using
DBUtils#getSchema(String, int, int, int, String) |
static List<io.cdap.cdap.api.data.schema.Schema.Field> |
getSchemaFields(io.cdap.cdap.api.data.schema.Schema resultsetSchema,
String schemaStr)
Given the result set, get the metadata of the result set and return
list of
Schema.Field,
where name of the field is same as column name and type of the field is obtained using
DBUtils#getSchema(String, int, int, int, String) |
static Object |
transformValue(int sqlType,
int precision,
int scale,
ResultSet resultSet,
String fieldName) |
public static final String OVERRIDE_SCHEMA
public static final String PATTERN_TO_REPLACE
public static final String REPLACE_WITH
public static final String CONNECTION_ARGUMENTS
public static final String FETCH_SIZE
public static void cleanup(Class<? extends Driver> driverClass)
driverClass - the JDBC driver classpublic static DriverCleanup ensureJDBCDriverIsAvailable(Class<? extends Driver> jdbcDriverClass, String connectionString, String jdbcPluginType, String jdbcPluginName) throws IllegalAccessException, InstantiationException, SQLException
DriverManager if it is not already registered.public static List<io.cdap.cdap.api.data.schema.Schema.Field> getSchemaFields(io.cdap.cdap.api.data.schema.Schema resultsetSchema, @Nullable String schemaStr)
Schema.Field,
where name of the field is same as column name and type of the field is obtained using
DBUtils#getSchema(String, int, int, int, String)resultsetSchema - the schema from the dbschemaStr - schema string to override resultant schemapublic static List<io.cdap.cdap.api.data.schema.Schema.Field> getOriginalSchema(ResultSet resultSet) throws SQLException
Schema.Field,
where name of the field is same as column name and type of the field is obtained using
DBUtils#getSchema(int, int, int)resultSet - result set of executed querySQLExceptionpublic static List<io.cdap.cdap.api.data.schema.Schema.Field> getSchemaFields(ResultSet resultSet, @Nullable String patternToReplace, @Nullable String replaceWith) throws SQLException
Schema.Field,
where name of the field is same as column name and type of the field is obtained using
DBUtils#getSchema(String, int, int, int, String)resultSet - result set of executed querypatternToReplace - the pattern to replace in the field namereplaceWith - the replacement value, if it is null, the pattern will be removedSQLException@Nullable public static Object transformValue(int sqlType, int precision, int scale, ResultSet resultSet, String fieldName) throws SQLException
SQLExceptionpublic static void deregisterAllDrivers(Class<? extends Driver> driverClass) throws NoSuchFieldException, IllegalAccessException, ClassNotFoundException
Copyright © 2020 CDAP Licensed under the Apache License, Version 2.0.