DBCommand sysDBCommand = sysDB.createCommand();
sysDBCommand.select(sysDB.CI.getColumns());
sysDBCommand.where (sysDB.CI.C_OWNER.is(owner));
OracleDataDictionnary dataDictionnary = new OracleDataDictionnary();
DBReader rd = new DBReader();
try
{
rd.open(sysDBCommand, conn);
// read all
log.info("---------------------------------------------------------------------------------");
log.info("checkDatabase start: " + db.getClass().getName());
String skipTable = "";
while (rd.moveNext())
{
String tableName = rd.getString(sysDB.CI.C_TABLE_NAME);
// if a table wasn't found before, skip it
if (tableName.equals(skipTable))
continue;
// check if the found table exists in the DBDatabase object
String columnName = rd.getString(sysDB.CI.C_COLUMN_NAME);
DBTable dbTable = db.getTable(tableName);
DBView dbView = db.getView(tableName);
String dataType = rd.getString(sysDB.CI.C_DATA_TYPE);
int charLength = rd.getInt(sysDB.CI.C_CHAR_LENGTH);
int dataLength = rd.getInt(sysDB.CI.C_DATA_LENGTH);
int dataPrecision = rd.getInt(sysDB.CI.C_DATA_PRECISION);
int dataScale = rd.getInt(sysDB.CI.C_DATA_SCALE);
String nullable = rd.getString(sysDB.CI.C_NULLABLE);
dataDictionnary.fillDataDictionnary(tableName, columnName, dataType,
charLength, dataLength, dataPrecision, dataScale, nullable);
if (dbTable != null)
{
// check if the found column exists in the found DBTable
DBColumn col = dbTable.getColumn(columnName);
if (col == null)
{
log.warn("COLUMN NOT FOUND IN " + db.getClass().getName() + "\t: [" + tableName + "]["
+ columnName + "][" + dataType + "][" + dataLength + "]");
continue;
}
/*
else
{ // check the DBTableColumn definition
int length = (charLength>0) ? charLength : dataLength;
dataDictionnary.checkColumnDefinition(col, dataType, length, dataPrecision, dataScale, nullable.equals("N"));
}
*/
}
else if (dbView!=null)
{
log.debug("Column check for view " + tableName + " not yet implemented.");
}
else
{
log.debug("TABLE OR VIEW NOT FOUND IN " + db.getClass().getName() + "\t: [" + tableName + "]");
// skip this table
skipTable = tableName;
continue;
}
}
// check Tables
dataDictionnary.checkDBTableDefinition(db.getTables());
// check Views
dataDictionnary.checkDBViewDefinition (db.getViews());
// done
log.info("checkDatabase end: " + db.getClass().getName());
log.info("---------------------------------------------------------------------------------");
} finally {
// close
rd.close();
}
}