/**
*
* @param sourceConn
* @param ti
* @param column
* @return
* @throws SQLException
*/
/**
* @param sourceConn
* @param ti
* @param column
* @return
* @throws SQLException
*/
public static String getColumnName(ISQLConnection sourceConn, ITableInfo ti, int column) throws SQLException {
TableColumnInfo[] infoArr = sourceConn.getSQLMetaData().getColumnInfo(ti);
TableColumnInfo colInfo = infoArr[column];
return colInfo.getColumnName();
}
/**
*
* @param sourceConn
* @param ti
* @return
* @throws SQLException
*/
/**
* @param sourceConn
* @param ti
* @return
* @throws SQLException
*/
public static String[] getColumnNames(ISQLConnection sourceConn, ITableInfo ti) throws SQLException {
TableColumnInfo[] infoArr = sourceConn.getSQLMetaData().getColumnInfo(ti);
String[] result = new String[infoArr.length];
for (int i = 0; i < result.length; i++) {
TableColumnInfo colInfo = infoArr[i];
result[i] = colInfo.getColumnName();
}
return result;
}
/**
*
* @param columnList
* @param ti
* @return
* @throws SQLException
*/
/**
* @param columnList
* @param ti
* @return
* @throws SQLException
*/
public static String getSelectQuery(SessionInfoProvider prov, String columnList, ITableInfo ti) throws SQLException, UserCancelledOperationException {
StringBuilder result = new StringBuilder("select ");
result.append(columnList);
result.append(" from ");
ISession sourceSession = prov. [[#variable1af26740]]();
// String sourceSchema = null;
// MySQL uses catalogs instead of schemas
/*
if (DialectFactory.isMySQLSession(sourceSession)) {
if (log.isDebugEnabled()) {
String catalog =
prov.getSourceSelectedDatabaseObjects()[0].getCatalogName();
String schema =
prov.getSourceSelectedDatabaseObjects()[0].getSchemaName();
log.debug("Detected MySQL, using catalog ("+catalog+") " +
"instead of schema ("+schema+")");
}
sourceSchema =
prov.getSourceSelectedDatabaseObjects()[0].getCatalogName();
} else {
sourceSchema =
prov.getSourceSelectedDatabaseObjects()[0].getSchemaName();
}
*/
String tableName = getQualifiedObjectName(sourceSession, ti.getCatalogName(), ti.getSchemaName(), ti.getSimpleName(), DialectFactory.SOURCE_TYPE);
result.append(tableName);
return result.toString();
}
|