| java.lang.Object workbench.util.SqlUtil
SqlUtil | public class SqlUtil (Code) | | Methods for manipulating and analyzing SQL statements.
|
Method Summary | |
public static String | buildExpression(WbConnection conn, String catalog, String schema, String name) | public static void | closeAll(ResultSet rs, Statement stmt) | public static void | closeResult(ResultSet rs) | public static void | closeStatement(Statement stmt) | public static String | getCreateType(CharSequence sql) Returns the type that is beeing created e.g. | public static String | getDeleteTable(CharSequence sql) | public static String | getFromPart(String sql) Extract the FROM part of a SQL statement. | public static int | getFromPosition(String sql) | public static String | getInsertTable(CharSequence sql) If the given SQL is an INSERT INTO... | public static int | getKeywordPosition(String keyword, CharSequence sql) | public static int | getKeywordPosition(Set<String> keywords, CharSequence sql) | public static ResultInfo | getResultInfoFromQuery(String sql, WbConnection conn) | public static List<ColumnIdentifier> | getResultSetColumns(String sql, WbConnection conn) Returns the columns for the result set defined by the passed
query. | public static List<String> | getSelectColumns(String select, boolean includeAlias) Parse the given SQL SELECT query and return the columns defined
in the column list. | public static String | getSqlTypeDisplay(String aTypeName, int sqlType, int size, int digits) Construct the SQL display name for the given SQL datatype. | public static String | getSqlVerb(CharSequence sql) Returns the SQL Verb for the given SQL string. | public static List | getTables(String aSql) | public static List<String> | getTables(String sql, boolean includeAlias) Returns a List of tables defined in the SQL query. | final public static String | getTypeName(int aSqlType) | public static String | getUpdateTable(CharSequence sql) | public static CharSequence | getWarnings(WbConnection con, Statement stmt) | public static int | getWherePosition(String sql) | final public static boolean | isBlobType(int aSqlType) | final public static boolean | isCharacterType(int aSqlType) | final public static boolean | isClobType(int aSqlType) | final public static boolean | isClobType(int aSqlType, DbSettings dbInfo) | final public static boolean | isDateType(int aSqlType) | final public static boolean | isDecimalType(int aSqlType, int aScale, int aPrecision) | final public static boolean | isIntegerType(int aSqlType) | final public static boolean | isNumberType(int aSqlType) | final public static boolean | isStringType(int aSqlType) Returns true if the given JDBC type maps to the String class. | public static String | makeCleanSql(String aSql, boolean keepNewlines) | public static String | makeCleanSql(String aSql, boolean keepNewlines, char quote) | public static String | makeCleanSql(String aSql, boolean keepNewlines, boolean keepComments, char quote) | public static String | quoteObjectname(String object) | public static String | quoteObjectname(String aColname, boolean quoteAlways) | public static String | stripVerb(String sql) Removes the SQL verb of this command. | public static String | striptColumnAlias(String expression) |
closeAll | public static void closeAll(ResultSet rs, Statement stmt)(Code) | | Convenience method to close a ResultSet and a Statement without
a possible SQLException
|
closeResult | public static void closeResult(ResultSet rs)(Code) | | Convenience method to close a ResultSet without a possible
SQLException
|
closeStatement | public static void closeStatement(Statement stmt)(Code) | | Convenience method to close a Statement without a possible
SQLException
|
getCreateType | public static String getCreateType(CharSequence sql)(Code) | | Returns the type that is beeing created e.g. TABLE, VIEW, PROCEDURE
|
getDeleteTable | public static String getDeleteTable(CharSequence sql)(Code) | | If the given SQL is a DELETE [FROM] returns
the table from which rows will be deleted
|
getFromPart | public static String getFromPart(String sql)(Code) | | Extract the FROM part of a SQL statement. That is anything after the FROM
up to (but not including) the WHERE, GROUP BY, ORDER BY, whichever comes first
|
getFromPosition | public static int getFromPosition(String sql)(Code) | | Return the position of the FROM keyword in the given SQL
|
getInsertTable | public static String getInsertTable(CharSequence sql)(Code) | | If the given SQL is an INSERT INTO...
returns the target table, otherwise null
|
getResultSetColumns | public static List<ColumnIdentifier> getResultSetColumns(String sql, WbConnection conn) throws SQLException(Code) | | Returns the columns for the result set defined by the passed
query.
This method will actually execute the given SQL query, but will
not retrieve any rows (using setMaxRows(1).
|
getSelectColumns | public static List<String> getSelectColumns(String select, boolean includeAlias)(Code) | | Parse the given SQL SELECT query and return the columns defined
in the column list. If the SQL string does not start with SELECT
returns an empty List
Parameters: select - the SQL String to parse Parameters: includeAlias - if false, the "raw" column names will be returned, otherwisethe column name including the alias (e.g. "p.name AS person_name" a List of String objecs. |
getSqlTypeDisplay | public static String getSqlTypeDisplay(String aTypeName, int sqlType, int size, int digits)(Code) | | Construct the SQL display name for the given SQL datatype.
This is used when re-recreating the source for a table
|
getTables | public static List<String> getTables(String sql, boolean includeAlias)(Code) | | Returns a List of tables defined in the SQL query. If the
query is not a SELECT query the result is undefined
|
getTypeName | final public static String getTypeName(int aSqlType)(Code) | | |
getUpdateTable | public static String getUpdateTable(CharSequence sql)(Code) | | If the given SQL command is an UPDATE command, return
the table that is updated, otherwise return null;
|
getWherePosition | public static int getWherePosition(String sql)(Code) | | |
isBlobType | final public static boolean isBlobType(int aSqlType)(Code) | | |
isCharacterType | final public static boolean isCharacterType(int aSqlType)(Code) | | Returns true if the given JDBC type indicates some kind of
character data (including CLOBs)
|
isClobType | final public static boolean isClobType(int aSqlType)(Code) | | |
isClobType | final public static boolean isClobType(int aSqlType, DbSettings dbInfo)(Code) | | |
isDateType | final public static boolean isDateType(int aSqlType)(Code) | | |
isDecimalType | final public static boolean isDecimalType(int aSqlType, int aScale, int aPrecision)(Code) | | returns true if the passed data type (from java.sql.Types)
indicates a data type which can hold numeric values with
decimals
|
isIntegerType | final public static boolean isIntegerType(int aSqlType)(Code) | | returns true if the passed JDBC data type (from java.sql.Types)
indicates a data type which maps to a integer type
|
isNumberType | final public static boolean isNumberType(int aSqlType)(Code) | | Returns true if the passed datatype (from java.sql.Types)
can hold a numeric value (either with or without decimals)
|
isStringType | final public static boolean isStringType(int aSqlType)(Code) | | Returns true if the given JDBC type maps to the String class. This
returns fals for CLOB data.
|
makeCleanSql | public static String makeCleanSql(String aSql, boolean keepNewlines, char quote)(Code) | | |
makeCleanSql | public static String makeCleanSql(String aSql, boolean keepNewlines, boolean keepComments, char quote)(Code) | | Replaces all white space characters with ' ' (But not inside
string literals) and removes -- style and Java style comments
Parameters: aSql - The sql script to "clean out" Parameters: keepNewlines - if true, newline characters (\n) are kept Parameters: keepComments - if true, comments (single line, block comments) are kept Parameters: quote - The quote character String |
quoteObjectname | public static String quoteObjectname(String aColname, boolean quoteAlways)(Code) | | |
|
|