|
com.im.commons.db 5.9.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.im.commons.db.util.DBUtils
public class DBUtils
Class collecting a few generic static utility methods mostly related to SQL generation
| Field Summary | |
|---|---|
static String |
PROP_LOG_SQL_STATEMENTS
Property for option triggering SQL statements logging |
static String |
UNDERSCORE
|
| Constructor Summary | |
|---|---|
DBUtils()
|
|
| Method Summary | |
|---|---|
static PreparedStatementCreator |
createPreparedStatementCreator(String sql,
DBType dbType)
Create a PreparedStatementCreator with maximum optimal fetch size for given dbType. |
static PreparedStatementCreator |
createPreparedStatementCreator(String sql,
int fetchSize)
Create a PreparedStatementCreator, specifying some options for how the PreparedStatement should be created |
static DBDatabaseInfo.ColumnSQLType |
findColumnType(String nativeType)
Find the ColumnSQLType enum for this native type. |
static String |
findStringNotPresent(List<String> values)
Helper method for JChem cartridge functions to find a String (character) that is not present in any of the specified values |
static String[] |
getColumnNamesAsArray(List<DBColInfo> cols)
|
static List<String> |
getColumnNamesAsList(List<DBColInfo> cols)
|
static String[] |
getColumnNamesFor(DBTableInfo info,
String[] exceptThese)
|
static String |
join(Collection terms,
String sep)
Join a List of values with the specified separator |
static String |
join(int[] terms,
String sep)
Substitute an array of ids into a statement separated with the specified separator |
static String |
join(Object[] terms,
String sep)
Join the array of values with the specified separator |
static String |
join(Object[] terms,
String sep,
String identifierQuoteString)
Join the array of values with the specified separator and quote char |
static void |
join(StringBuffer buf,
Collection terms,
String sep,
int jdbcType)
Join a List of values with the specified separator and append to the specified StringBuffer |
static void |
join(StringBuffer buf,
Object[] terms,
String sep)
Join the array of values with the specified separator and append to the specified StringBuffer |
static String |
repeat(String val,
String sep,
int count)
|
static String |
schemaNameNoTable(String tableName)
Parses schema name from schema qualified table name. |
static String |
sqlEscapeString(Object o)
|
static String[] |
sqlEscapeString(Object[] o)
|
static String |
sqlQuoteAndEscapeString(Object o)
|
static String[] |
sqlQuoteAndEscapeString(Object[] o)
|
static String |
sqlQuoteString(Object o)
|
static String[] |
sqlQuoteString(Object[] o)
|
static String |
stripQuotes(String txt)
Strips the quotes (') from a string. |
static String |
tableNameNoSchema(String name)
Get the table name component of a table that might have a schema specified. |
static void |
verifySchemaQualifiedTableName(String tableName)
Verifies that table name contains '.', ie. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PROP_LOG_SQL_STATEMENTS
public static final String UNDERSCORE
| Constructor Detail |
|---|
public DBUtils()
| Method Detail |
|---|
public static String repeat(String val,
String sep,
int count)
public static String join(int[] terms,
String sep)
terms - The values to joinsep - The separator
public static String join(Collection terms,
String sep)
terms - A Collection of values whose values (according to the toString()
method) are joined togethersep - The separator to use
public static void join(StringBuffer buf,
Collection terms,
String sep,
int jdbcType)
buf - The buffer to append the results toterms - A Collection of values whose values (according to the toString()
method) are joined togethersep - The separator to usejdbcType - THe JDBC type which is used to determine if the values need
quoting and escaping
public static void join(StringBuffer buf,
Object[] terms,
String sep)
buf - The buffer to append the results toterms - An array of values whose values (according to the toString()
method) are joined togethersep - The separator to use
public static String join(Object[] terms,
String sep)
terms - An array of values whose values (according to the toString()
method) are joined togethersep - The separator to use
public static String join(Object[] terms,
String sep,
String identifierQuoteString)
terms - An array of values whose values (according to the toString()
method) are joined togethersep - The separator to useidentifierQuoteString - quote char surrounding each term
public static String sqlEscapeString(Object o)
public static String sqlQuoteString(Object o)
public static String sqlQuoteAndEscapeString(Object o)
public static String[] sqlEscapeString(Object[] o)
public static String[] sqlQuoteString(Object[] o)
public static String[] sqlQuoteAndEscapeString(Object[] o)
public static String stripQuotes(String txt)
public static String[] getColumnNamesFor(DBTableInfo info,
String[] exceptThese)
public static List<String> getColumnNamesAsList(List<DBColInfo> cols)
public static String[] getColumnNamesAsArray(List<DBColInfo> cols)
public static DBDatabaseInfo.ColumnSQLType findColumnType(String nativeType)
nativeType - The column type as a String. e.g. VARCHAR
public static String tableNameNoSchema(String name)
public static void verifySchemaQualifiedTableName(String tableName)
tableName - The t ableName to checkpublic static String schemaNameNoTable(String tableName)
tableName -
public static String findStringNotPresent(List<String> values)
public static PreparedStatementCreator createPreparedStatementCreator(String sql,
int fetchSize)
sql - The sql to usefetchSize - The JDBC fetch size. See Statement.setFetchSize(int)
public static PreparedStatementCreator createPreparedStatementCreator(String sql,
DBType dbType)
Statement.setFetchSize(int)
sql - The sql to usedbType - given dbType.
|
com.im.commons.db 5.9.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||