public class SQLUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SQLUtils.DbFeature |
Modifier and Type | Field and Description |
---|---|
static int |
DB_12C |
static int |
DB_18C |
static int |
DB_19C |
static int |
DB_20C |
static int |
DB_21C |
static int |
DB_MINOR_VERSION_DEFAULT |
static java.lang.String |
OPG_PATCH_NOT_INSTALLED |
static int |
ORA_INVALID_ID
This constant denotes the Oracle error code for invalid ID
|
static int |
ORA_LITERAL_TOO_LONG
This constant denotes the Oracle error code for string literal too long
|
Constructor and Description |
---|
SQLUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
castRDBMSObject(java.lang.Object obj, java.lang.Class dtClass) |
static java.lang.String |
checkSQLName(java.lang.String string, int maxStringLength)
Checks for any illegal characters in a SQL name.
|
static void |
createInitialProcedure(java.sql.Connection conn, java.lang.String procedureStr) |
static java.lang.String |
enquoteColumnName(java.sql.Connection conn, java.lang.String columnName)
Enquotes a column name.
|
static java.lang.String |
enquoteColumnNameCaseSensitive(java.sql.Connection conn, java.lang.String name)
Enquotes a column name.
|
static java.lang.String |
enquoteLiteral(java.sql.Connection conn, java.lang.String name)
This method enquotes a literal value.
|
static java.lang.String |
enquoteLiteral(java.sql.Connection conn, java.lang.String literal, int maxLengthAllowed)
Returns the enquoted literal
|
static java.lang.String |
enquoteNameSQLName(java.sql.Connection conn, java.lang.String name)
Returns the ENQUOTE_NAME formatted String for the SQL name If the Oracle JDBC is present, use the new OracleStatement.enquoteIdentifier API in the JDK8 JDBC.
|
static java.lang.String |
enquoteTableName(java.sql.Connection conn, java.lang.String tableName)
Enquotes a table name with or without schema name which is separated by ".".
|
static int |
getDatabaseMajorVersion(java.sql.Connection conn)
Gets Database Version of the given connection
|
static int |
getMaxLengthAllowed(java.sql.Connection conn)
Checks if the specified name is a qualified SQL name.
|
static java.lang.String |
getOpgVersion(java.sql.Connection conn)
Gets OPG pl/sql packages version installed
|
static java.lang.String |
getValidatedGraphName(java.sql.Connection conn, java.lang.String graphName)
Returns the validated graph name
|
static java.lang.String |
getValidatedGraphName(java.sql.Connection conn, java.lang.String graphName, int maxLengthAllowed)
Returns the validated graph name
|
static boolean |
isEnterpriseEditionDB(java.sql.Connection conn)
Finds if Database of the given connection is Enterprise Edition
|
static boolean |
isMaxStringSizeExtended(java.sql.Connection conn)
Finds if max_str_size parameter value is extended in the given DB connection
|
static boolean |
isOpgPatchInstalled(java.lang.String opgVersion)
Checks if the OPG pl/sql patch is installed in a DB with given OPG version
|
static java.lang.String |
myCheckName(java.lang.String string)
Checks for any illegal characters in a SQL name.
|
static java.lang.String |
qualifiedSQLName(java.sql.Connection conn, java.lang.String name)
Checks if the specified name is a qualified SQL name.
|
static void |
setEventForPartitioning(java.sql.Connection connection, int level)
Sets level for partitioning enable/disable event (1 to turn off, 0 to turn on)
|
static void |
setStmtArgumentForDml(int idx, java.sql.PreparedStatement ps, java.lang.String szKey, java.lang.Object objVa1) |
static java.lang.String |
simpleSqlNameCheck(java.sql.Connection conn, java.lang.String name)
This method returns the result of OracleStatement.enquoteIdentifier function: If identifier is a simple SQL identifier, the original value is returned A SQLException will be thrown if identifier contains any characters invalid in a delimited identifier or the identifier length is invalid for the datasource.
|
static java.lang.String |
stripSchema(java.sql.Connection connection, java.lang.String tabName) |
static boolean |
validateIsNumericColumn(int sqlType) |
public static final int DB_12C
public static final int DB_18C
public static final int DB_19C
public static final int DB_20C
public static final int DB_21C
public static final int DB_MINOR_VERSION_DEFAULT
public static final java.lang.String OPG_PATCH_NOT_INSTALLED
public static final int ORA_INVALID_ID
public static final int ORA_LITERAL_TOO_LONG
public static final java.lang.Object castRDBMSObject(java.lang.Object obj, java.lang.Class dtClass)
public static java.lang.String checkSQLName(java.lang.String string, int maxStringLength) throws java.sql.SQLException
string
- input stringmaxStringLength
- maximum length for input stringjava.sql.SQLException
- An exception is thrown if the input string contains any illegal characters or exceeds the maximum lengthpublic static void createInitialProcedure(java.sql.Connection conn, java.lang.String procedureStr)
public static java.lang.String enquoteColumnName(java.sql.Connection conn, java.lang.String columnName) throws java.sql.SQLException
conn
-columnName
-java.sql.SQLException
public static java.lang.String enquoteColumnNameCaseSensitive(java.sql.Connection conn, java.lang.String name) throws java.sql.SQLException
java.sql.SQLException
public static java.lang.String enquoteLiteral(java.sql.Connection conn, java.lang.String name) throws java.sql.SQLException
conn
- the database connectionname
- the input literaljava.sql.SQLException
- A SQLexception is thrown if the dbms_assert.qualified_sql_name failedpublic static java.lang.String enquoteLiteral(java.sql.Connection conn, java.lang.String literal, int maxLengthAllowed) throws java.sql.SQLException
conn
- the database connectionliteral
- the input namejava.sql.SQLException
public static java.lang.String enquoteNameSQLName(java.sql.Connection conn, java.lang.String name) throws java.sql.SQLException
conn
- the database connectionname
- the input namejava.sql.SQLException
public static java.lang.String enquoteTableName(java.sql.Connection conn, java.lang.String tableName) throws java.sql.SQLException
conn
-tableName
-java.sql.SQLException
public static int getDatabaseMajorVersion(java.sql.Connection conn)
public static int getMaxLengthAllowed(java.sql.Connection conn)
conn
- the database connectionpublic static java.lang.String getOpgVersion(java.sql.Connection conn)
conn
- The JDBC DB connectionpublic static java.lang.String getValidatedGraphName(java.sql.Connection conn, java.lang.String graphName) throws java.sql.SQLException
conn
- the database connectiongraphName
- the input graph namejava.sql.SQLException
public static java.lang.String getValidatedGraphName(java.sql.Connection conn, java.lang.String graphName, int maxLengthAllowed) throws java.sql.SQLException
conn
- the database connectiongraphName
- the input graph namejava.sql.SQLException
public static boolean isEnterpriseEditionDB(java.sql.Connection conn)
public static boolean isMaxStringSizeExtended(java.sql.Connection conn)
conn
- The connection to DB to checkpublic static boolean isOpgPatchInstalled(java.lang.String opgVersion)
opgVersion
- The OPG versionpublic static java.lang.String myCheckName(java.lang.String string) throws java.sql.SQLException
string
- input stringjava.sql.SQLException
- An exception is thrown if the input string contains any illegal characters or exceeds the maximum lengthpublic static java.lang.String qualifiedSQLName(java.sql.Connection conn, java.lang.String name) throws java.sql.SQLException
conn
- the database connectionname
- the input namejava.sql.SQLException
- A SQLexception is thrown if the dbms_assert.qualified_sql_name failedpublic static void setEventForPartitioning(java.sql.Connection connection, int level) throws java.sql.SQLException
java.sql.SQLException
public static void setStmtArgumentForDml(int idx, java.sql.PreparedStatement ps, java.lang.String szKey, java.lang.Object objVa1) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public static java.lang.String simpleSqlNameCheck(java.sql.Connection conn, java.lang.String name) throws java.sql.SQLException
conn
- the database connectionname
- the input literaljava.sql.SQLException
- A SQLexception is thrown if the assertion failedpublic static java.lang.String stripSchema(java.sql.Connection connection, java.lang.String tabName) throws java.sql.SQLException
java.sql.SQLException
public static boolean validateIsNumericColumn(int sqlType)