|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.squirrel_sql.plugins.dbdiff.util.DBUtil
public class DBUtil
A utility class for interacting with the database.
| Constructor Summary | |
|---|---|
DBUtil()
|
|
| Method Summary | |
|---|---|
static boolean |
containsTable(List<ITableInfo> tableInfos,
String table)
|
static ResultSet |
executeQuery(ISession session,
String sql)
Executes the specified sql statement on the specified connection and returns the ResultSet. |
static String |
fixCase(ISession session,
String identifier)
Uppercase / Lowercase / Mixedcase identifiers are a big problem. |
static String |
getCatSep(ISession session)
|
static int |
getColumnCount(ISQLConnection sourceConn,
ITableInfo ti)
|
static String |
getColumnList(TableColumnInfo[] colInfoArr)
|
static String |
getColumnName(ISQLConnection sourceConn,
ITableInfo ti,
int column)
|
static String[] |
getColumnNames(ISQLConnection sourceConn,
ITableInfo ti)
|
static int |
getColumnType(ISQLConnection con,
ITableInfo ti,
int column)
|
static int |
getColumnType(ISQLConnection con,
ITableInfo ti,
String columnName)
|
static int[] |
getColumnTypes(ISQLConnection con,
ITableInfo ti)
|
static int[] |
getColumnTypes(ISQLConnection con,
ITableInfo ti,
String[] colNames)
|
static String |
getLastStatement()
|
static String |
getLastStatementValues()
|
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. |
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. |
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). |
static String |
getSelectQuery(SessionInfoProvider prov,
String columnList,
ITableInfo ti)
|
static int |
getTableCount(ISession session,
String catalog,
String schema,
String tableName,
int sessionType)
Returns a count of the records in the specified table. |
static ITableInfo |
getTableInfo(ISession session,
String schema,
String tableName)
|
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. |
static int |
replaceOtherDataType(TableColumnInfo colInfo)
Takes the specified colInfo, gets the data type to see if it is 1111(OTHER). |
static boolean |
sameDatabaseType(ISession session1,
ISession session2)
|
static void |
setLastStatement(String lastStatement)
|
static void |
setLastStatementValues(String values)
|
static boolean |
tableHasForeignKey(String destCatalog,
String destSchema,
String destTableName,
ForeignKeyInfo fkInfo,
SessionInfoProvider prov)
|
static boolean |
tableHasPrimaryKey(ISQLConnection con,
ITableInfo ti)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DBUtil()
| Method Detail |
|---|
public static String getPKColumnString(ISQLConnection sourceConn,
ITableInfo ti)
throws SQLException
sourceConn - ti -
SQLException
public static boolean tableHasForeignKey(String destCatalog,
String destSchema,
String destTableName,
ForeignKeyInfo fkInfo,
SessionInfoProvider prov)
public static boolean containsTable(List<ITableInfo> tableInfos,
String table)
public static ResultSet executeQuery(ISession session,
String sql)
throws SQLException
con - sql - mysqlBigResultFix - if true, provides a work-around which is useful in the case that the connection is to a MySQL
database. If the number of rows is large this will prevent the driver from reading them all
into client memory. MySQL's normal practice is to do such a thing for performance reasons.
Exception
SQLException
public static int getTableCount(ISession session,
String catalog,
String schema,
String tableName,
int sessionType)
throws UserCancelledOperationException
con - the SQLConnection to use to execute the count query.tableName - the name of the table
UserCancelledOperationException
public static ITableInfo getTableInfo(ISession session,
String schema,
String tableName)
throws SQLException,
org.hibernate.MappingException,
UserCancelledOperationException
SQLException
org.hibernate.MappingException
UserCancelledOperationException
public static int replaceOtherDataType(TableColumnInfo colInfo)
throws org.hibernate.MappingException
colInfo -
org.hibernate.MappingException
public static int getColumnType(ISQLConnection con,
ITableInfo ti,
String columnName)
throws SQLException
con - synonym - columnName -
SQLException
public static int[] getColumnTypes(ISQLConnection con,
ITableInfo ti,
String[] colNames)
throws SQLException
SQLException
public static boolean tableHasPrimaryKey(ISQLConnection con,
ITableInfo ti)
throws SQLException
SQLException
public static String getColumnList(TableColumnInfo[] colInfoArr)
throws SQLException
con - ti -
SQLException
public static String getColumnName(ISQLConnection sourceConn,
ITableInfo ti,
int column)
throws SQLException
sourceConn - ti - column -
SQLException
public static String[] getColumnNames(ISQLConnection sourceConn,
ITableInfo ti)
throws SQLException
sourceConn - ti -
SQLException
public static String getSelectQuery(SessionInfoProvider prov,
String columnList,
ITableInfo ti)
throws SQLException,
UserCancelledOperationException
columnList - ti -
SQLException
UserCancelledOperationExceptionpublic static boolean isBinaryType(TableColumnInfo columnInfo)
columnInfo - the TableColumnInfo to examine
public static String getQualifiedObjectName(ISession session,
String catalogName,
String schemaName,
String objectName,
int sessionType)
throws UserCancelledOperationException
session - catalogName - schemaName - objectName -
UserCancelledOperationExceptionpublic static String getCatSep(ISession session)
public static String fixCase(ISession session,
String identifier)
session - the session whose disposition on case we care about.identifier -
public static int getColumnCount(ISQLConnection sourceConn,
ITableInfo ti)
throws SQLException
sourceConn - ti -
SQLException
public static int getColumnType(ISQLConnection con,
ITableInfo ti,
int column)
throws SQLException
con - ti - column -
SQLException
public static int[] getColumnTypes(ISQLConnection con,
ITableInfo ti)
throws SQLException
SQLException
public static boolean sameDatabaseType(ISession session1,
ISession session2)
public static String getMaxColumnLengthSQL(ISession sourceSession,
TableColumnInfo colInfo,
String tableName,
boolean tableNameIsQualified)
throws UserCancelledOperationException
sourceSession - colInfo - tableName - tableNameIsQualified - whether or not the specified tableName is qualified.
UserCancelledOperationExceptionpublic static void setLastStatement(String lastStatement)
lastStatement - the lastStatement to setpublic static String getLastStatement()
public static void setLastStatementValues(String values)
public static String getLastStatementValues()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||