//this.resultColumns = new HashSet<String>();
try {
ResultSetMetaData rsMetaData = resultSet.getMetaData();
if (rsMetaData == null) {
throw new DbOomException("No ResultSet meta-data");
}
totalColumns = rsMetaData.getColumnCount();
this.resultColumns = new HashSet<String>(totalColumns);
columnNames = new String[totalColumns];
columnDbSqlTypes = new int[totalColumns];
tableNames = new String[totalColumns];
for (int i = 0; i < totalColumns; i++) {
String columnName = rsMetaData.getColumnLabel(i + 1);
if (columnName == null) {
columnName = rsMetaData.getColumnName(i + 1);
}
String tableName = null;
// resolve column and table name
int sepNdx = columnName.indexOf(dbOomManager.getColumnAliasSeparator());
if (sepNdx != -1) {
// column alias exist, result set is ignored and columnAliases contains table data
tableName = columnName.substring(0, sepNdx);
if (columnAliases != null) {
ColumnData columnData = columnAliases.get(tableName);
if (columnData != null) {
tableName = columnData.getTableName();
}
}
columnName = columnName.substring(sepNdx + 1);
} else {
// column alias does not exist, table name is read from columnAliases and result set (if available)
if (columnAliases != null) {
ColumnData columnData = columnAliases.get(columnName);
if (columnData != null) {
tableName = columnData.getTableName();
columnName = columnData.getColumnName();
}
}
if (tableName == null) {
try {
tableName = rsMetaData.getTableName(i + 1);
} catch (SQLException sex) {
// ignore
}
if ((tableName != null) && (tableName.length() == 0)) {
tableName = null;
}
}
}
columnName = columnName.trim();
if (columnName.length() == 0) {
columnName = null;
}
if (columnName != null) {
columnName = columnName.trim();
columnName = columnName.toUpperCase();
}
columnNames[i] = columnName;
if (tableName != null) {
tableName = tableName.trim();
tableName = tableName.toUpperCase();
}
tableNames[i] = tableName;
columnDbSqlTypes[i] = rsMetaData.getColumnType(i + 1);
}
} catch (SQLException sex) {
throw new DbOomException(dbOomQuery, "Reading ResultSet meta-data failed", sex);
}
}