public static boolean sameDatabaseType(ISession session1, ISession session2) {
boolean result = false;
String driver1ClassName = session1.getDriver().getDriverClassName();
String driver2ClassName = session2.getDriver().getDriverClassName();
if (driver1ClassName.equals(driver2ClassName)) {
result = true;
}
return result;
}
/**
* Gets the SQL statement which can be used to select the maximum length of the current data found in
* tableName within the specified column.
*
* @param sourceSession
* @param colInfo
* @param tableName
* @param tableNameIsQualified
* whether or not the specified tableName is qualified.
* @return
*/
/**
* Gets the SQL statement which can be used to select the maximum length of the current data found in
* tableName within the specified column.
*
* @param sourceSession
* @param colInfo
* @param tableName
* @param tableNameIsQualified
* TODO
* @return
*/
public static String getMaxColumnLengthSQL(ISession sourceSession, TableColumnInfo colInfo, String tableName, boolean tableNameIsQualified) throws UserCancelledOperationException {
StringBuilder result = new StringBuilder();
HibernateDialect dialect = DialectFactory.getDialect(DialectFactory.SOURCE_TYPE, sourceSession.getApplication().getMainFrame(), sourceSession.getMetaData());
String lengthFunction = dialect.getLengthFunction(colInfo.getDataType());
if (lengthFunction == null) {
log.error("Length function is null for dialect=" + dialect.getClass().getName() + ". Using \'length\'");
lengthFunction = "length";
}
String maxFunction = dialect.getMaxFunction();
if (maxFunction == null) {
log.error("Max function is null for dialect=" + dialect.getClass().getName() + ". Using \'max\'");
maxFunction = "max";
}
result.append("select ");
result.append(maxFunction);
result.append("(");
result.append(lengthFunction);
result.append("(");
result.append(colInfo.getColumnName());
result.append(")) from ");
String table = tableName;
if ( !tableNameIsQualified) {
table = getQualifiedObjectName(sourceSession, colInfo.getCatalogName(), colInfo.getSchemaName(), tableName, DialectFactory.SOURCE_TYPE);
}
result.append(table);
return result.toString();
}
/**
* @param lastStatement
* the lastStatement to set
*/
/**
* @param lastStatement
* the lastStatement to set
*/
public static void setLastStatement(String lastStatement) {
DBUtil.lastStatement = lastStatement;
}
/**
* @return the lastStatement
*/
public static String getLastStatement() {
return lastStatement;
}
public static void setLastStatementValues(String values) {
lastStatementValues = values;
}
public static String getLastStatementValues() {
return lastStatementValues;
}
|