| java.lang.Object net.sourceforge.squirrel_sql.plugins.dbdiff.I18NBaseObject net.sourceforge.squirrel_sql.plugins.dbdiff.util.DBUtil
DBUtil | public class DBUtil extends I18NBaseObject (Code) | | A utility class for interacting with the database.
|
Method Summary | |
public static void | closeResultSet(ResultSet rs) Closes the specified ResultSet. | public static void | closeStatement(Statement stmt) Closes the specified Statement. | public static boolean | containsTable(List<ITableInfo> tableInfos, String table) | public static ResultSet | executeQuery(ISession session, String sql) Executes the specified sql statement on the specified connection and
returns the ResultSet.
Parameters: con - Parameters: sql - Parameters: mysqlBigResultFix - if true, provides a work-around which is usefulin the case that the connection is to a MySQL database. | public static String | fixCase(ISession session, String identifier) Uppercase / Lowercase / Mixedcase identifiers are a big problem. | public static String | getCatSep(ISession session) | public static int | getColumnCount(ISQLConnection sourceConn, ITableInfo ti) | public static String | getColumnList(TableColumnInfo[] colInfoArr) | public static String | getColumnName(ISQLConnection sourceConn, ITableInfo ti, int column) | public static String[] | getColumnNames(ISQLConnection sourceConn, ITableInfo ti) | public static int | getColumnType(ISQLConnection con, ITableInfo ti, String columnName) | public static int | getColumnType(ISQLConnection con, ITableInfo ti, int column) | public static int[] | getColumnTypes(ISQLConnection con, ITableInfo ti, String[] colNames) | public static int[] | getColumnTypes(ISQLConnection con, ITableInfo ti) | public static String | getLastStatement() | public static String | getLastStatementValues() | public static String | getMaxColumnLengthSQL(ISession sourceSession, TableColumnInfo colInfo, String tableName, boolean tableNameIsQualified) Gets the SQL statement which can be used to select the maximum length
of the current data found in tableName within the specified column. | public static String | getPKColumnString(ISQLConnection sourceConn, ITableInfo ti) Returns a string that looks like:
(PK_COL1, PK_COL2, PK_COL3, ...)
or null if there is no primary key for the specified table. | public static String | getQualifiedObjectName(ISession session, String catalogName, String schemaName, String objectName, int sessionType) Decide whether or not the session specified needs fully qualified table
names (schema.table). | public static String | getSelectQuery(SessionInfoProvider prov, String columnList, ITableInfo ti) | public static int | getTableCount(ISession session, String catalog, String schema, String tableName, int sessionType) Returns a count of the records in the specified table. | public static ITableInfo | getTableInfo(ISession session, String schema, String tableName) | public static boolean | isBinaryType(TableColumnInfo columnInfo) Returns a boolean value indicating whether or not the specified
TableColumnInfo represents a database column that holds binary type
data. | public static int | replaceOtherDataType(TableColumnInfo colInfo) Takes the specified colInfo, gets the data type to see if it is
1111(OTHER). | public static boolean | sameDatabaseType(ISession session1, ISession session2) | public static void | setLastStatement(String lastStatement) | public static void | setLastStatementValues(String values) | public static boolean | tableHasForeignKey(String destCatalog, String destSchema, String destTableName, ForeignKeyInfo fkInfo, SessionInfoProvider prov) | public static boolean | tableHasPrimaryKey(ISQLConnection con, ITableInfo ti) |
closeResultSet | public static void closeResultSet(ResultSet rs)(Code) | | Closes the specified ResultSet.
Parameters: rs - the ResultSet to close. |
closeStatement | public static void closeStatement(Statement stmt)(Code) | | Closes the specified Statement.
Parameters: stmt - the Statement to close. |
executeQuery | public static ResultSet executeQuery(ISession session, String sql) throws SQLException(Code) | | Executes the specified sql statement on the specified connection and
returns the ResultSet.
Parameters: con - Parameters: sql - Parameters: mysqlBigResultFix - if true, provides a work-around which is usefulin the case that the connection is to a MySQL database. If the number of rows is large this will prevent the driver from readingthem all into client memory. MySQL's normal practice is to do such a thing for performance reasons. throws: Exception - |
fixCase | public static String fixCase(ISession session, String identifier)(Code) | | Uppercase / Lowercase / Mixedcase identifiers are a big problem. Some
databases support mixing case (like McKoi) others force identifier case
to all uppercase or all lowercase. Some (like MySQL) can be configured
to care or not care about case as well as depending on the platform the
database is on. This method attempt to use the metadata from the driver
to "fix" the case of the identifier to be acceptable for the specified
session.
Parameters: session - the session whose disposition on case we care about. Parameters: identifier - |
getLastStatement | public static String getLastStatement()(Code) | | the lastStatement |
getLastStatementValues | public static String getLastStatementValues()(Code) | | |
getMaxColumnLengthSQL | public static String getMaxColumnLengthSQL(ISession sourceSession, TableColumnInfo colInfo, String tableName, boolean tableNameIsQualified) throws UserCancelledOperationException(Code) | | Gets the SQL statement which can be used to select the maximum length
of the current data found in tableName within the specified column.
Parameters: sourceSession - Parameters: colInfo - Parameters: tableName - Parameters: tableNameIsQualified - TODO |
getPKColumnString | public static String getPKColumnString(ISQLConnection sourceConn, ITableInfo ti) throws SQLException(Code) | | Returns a string that looks like:
(PK_COL1, PK_COL2, PK_COL3, ...)
or null if there is no primary key for the specified table.
Parameters: sourceConn - Parameters: ti - throws: SQLException - |
getQualifiedObjectName | public static String getQualifiedObjectName(ISession session, String catalogName, String schemaName, String objectName, int sessionType) throws UserCancelledOperationException(Code) | | Decide whether or not the session specified needs fully qualified table
names (schema.table). In most databases this is optional (Oracle).
In others it is required (Progress). In still others it must not occur.
(Axion, Hypersonic)
Parameters: session - Parameters: catalogName - Parameters: schemaName - Parameters: objectName - throws: UserCancelledOperationException - |
getTableCount | public static int getTableCount(ISession session, String catalog, String schema, String tableName, int sessionType) throws UserCancelledOperationException(Code) | | Returns a count of the records in the specified table.
Parameters: con - the SQLConnection to use to execute the count query. Parameters: tableName - the name of the table -1 if the table does not exist, otherwise the record count isreturned. |
isBinaryType | public static boolean isBinaryType(TableColumnInfo columnInfo)(Code) | | Returns a boolean value indicating whether or not the specified
TableColumnInfo represents a database column that holds binary type
data.
Parameters: columnInfo - the TableColumnInfo to examine true if binary; false otherwise. |
replaceOtherDataType | public static int replaceOtherDataType(TableColumnInfo colInfo) throws MappingException(Code) | | Takes the specified colInfo, gets the data type to see if it is
1111(OTHER). If so then get the type name and try to match a jdbc type
with the same name to get it's type code.
Parameters: colInfo - throws: MappingException - |
setLastStatement | public static void setLastStatement(String lastStatement)(Code) | | Parameters: lastStatement - the lastStatement to set |
setLastStatementValues | public static void setLastStatementValues(String values)(Code) | | |
|
|