boolean isRsOpen = true;
try
{
if (rs.next()) // proceed if rs contains a table description for our table
{
RDBMSIdentifierFactory idFactory = (RDBMSIdentifierFactory)storeMgr.getIdentifierFactory();
//close RS as soon as possible to release any locks it may have
if (rs.getStatement() != null)
{
rs.getStatement().close();
}
rs.close();
isRsOpen = false;
// Note : The table name has no quotes on it here. Some JDBC drivers (e.g Oracle 9i, 10g) fail here when
// the table name is an SQL keyword. This is likely an error in the JDBC driver
ResultSet rsIndexes = dba.getExistingIndexes(conn,dmd,c[0], c[1] == null ? getSchemaName() : c[1], c[2]);
try
{
boolean hasNext = rsIndexes.next();
if (!hasNext)
{
//ORACLE 10g: The SCHEMA name is mandatory for Oracle 10g, so if it was not given
//in the previous getExistingIndexes, it will be given here
rsIndexes = dba.getExistingIndexes(conn,dmd,c[0], storeMgr.getSchemaName(), c[2]);
hasNext = rsIndexes.next();
}
while (hasNext)
{
short idxType = rsIndexes.getShort(7);
if (idxType == DatabaseMetaData.tableIndexStatistic)
{
hasNext = rsIndexes.next();
continue;
}
String indexName=rsIndexes.getString(6);
DatastoreIdentifier idxName = idFactory.newIdentifier(IdentifierFactory.INDEX, indexName);
Index idx = (Index) indicesByName.get(idxName);
if (idx == null)
{
boolean isUnique = !rsIndexes.getBoolean(4);
idx = new Index(this, isUnique, null);
idx.setName(indexName);
indicesByName.put(idxName, idx);
}
// Set the column
int colSeq = rsIndexes.getShort(8) - 1;
DatastoreIdentifier colName = idFactory.newIdentifier(IdentifierFactory.COLUMN, rsIndexes.getString(9));
Column col = (Column) columnsByName.get(colName);
if (col != null)
{
idx.setColumn(colSeq, col);