public final class DbTypeHelper extends Object
Modifier | Constructor and Description |
---|---|
private |
DbTypeHelper() |
Modifier and Type | Method and Description |
---|---|
static String |
filterName(String dbType,
String str)
Filter a name (table name, column name, and so on) according to the database type
so that it can be passed to
DatabaseMetaData methods, such as getTables and getColumns. |
static String |
getBinaryType(String dbType)
Get the binary type identifier corresponding to the database type.
|
static String |
getBooleanType(String dbType)
Get the boolean type identifier corresponding to the database type.
|
static String |
getCurrentDateFunction(String dbType)
Get the "now" function (NOW(), CURDATE, ...)
|
static String |
getDateTimeType(String dbType)
Get the date and time type identifier corresponding to the database type.
|
static String |
getIdentityMarker(String dbType)
Get the "identity" string marker (AUTO_INCREMENT, SERIAL...)
|
static String |
getIdentityType(String dbType)
Get the "identity" type (int, integer, number, ...)
|
static String |
getIdentityValue(String dbType)
Get the "identity" value (NULL, sequence next val call, ...)
|
static String |
getIntegerType(String dbType)
Get the integer type identifier corresponding to the database type.
|
static String |
getRenameColumnStatement(String tableName,
FormTableManager.DbColumn column,
String newName,
String dbType,
SQLDatabaseTypeExtensionPoint sqlDatabaseTypeExtensionPoint)
Get a SQL statement to rename a column.
|
static String |
getRenameColumnStatement(String tableName,
String columnName,
String newName,
String columnType,
String dbType,
SQLDatabaseTypeExtensionPoint sqlDatabaseTypeExtensionPoint)
Get a SQL statement to rename a column.
|
static String |
getTextType(String dbType)
Get the text type identifier corresponding to the database type.
|
static String |
getVarcharType(String dbType)
Get the varchar type identifier corresponding to the database type.
|
static boolean |
insertIdentity(String dbType)
Test if we have to include the identity column in INSERTs.
|
static String |
normalizeName(String dbType,
String str)
Normalize a name (table name, column name, and so on) according to the database type.
|
static void |
setIdentity(PreparedStatement stmt,
int index,
String dbType)
Set the identity value into the statement.
|
private DbTypeHelper()
public static String normalizeName(String dbType, String str)
dbType
- the database type.str
- the string to normalize.public static String filterName(String dbType, String str)
DatabaseMetaData
methods, such as getTables and getColumns.dbType
- the database type.str
- the string to filter.public static String getVarcharType(String dbType)
dbType
- the database type.public static String getTextType(String dbType)
dbType
- the database type.public static String getBooleanType(String dbType)
dbType
- the database type.public static String getBinaryType(String dbType)
dbType
- the database type.public static String getIntegerType(String dbType)
dbType
- the database type.public static String getDateTimeType(String dbType)
dbType
- the database type.public static String getIdentityType(String dbType)
dbType
- the database type.public static String getIdentityMarker(String dbType)
dbType
- the database type.public static String getIdentityValue(String dbType)
dbType
- the database type.public static String getCurrentDateFunction(String dbType)
dbType
- the database type.public static boolean insertIdentity(String dbType)
dbType
- the database type.public static void setIdentity(PreparedStatement stmt, int index, String dbType) throws SQLException
stmt
- the prepared statement.index
- the column index.dbType
- the database type.SQLException
- if a SQL exception occurs.public static String getRenameColumnStatement(String tableName, FormTableManager.DbColumn column, String newName, String dbType, SQLDatabaseTypeExtensionPoint sqlDatabaseTypeExtensionPoint)
tableName
- the table name.column
- the column to rename.newName
- the new column name.dbType
- the database type.sqlDatabaseTypeExtensionPoint
- SQLDatabaseTypeExtensionPointpublic static String getRenameColumnStatement(String tableName, String columnName, String newName, String columnType, String dbType, SQLDatabaseTypeExtensionPoint sqlDatabaseTypeExtensionPoint)
tableName
- the table name.columnName
- the current column name.newName
- the new column name.columnType
- the full column type string (i.e TEXT, VARCHAR(255), INT(1), and so on).dbType
- the database type.sqlDatabaseTypeExtensionPoint
- SQLDatabaseTypeExtensionPoint