* the given ResultSet
*/
private DBTableColumn addColumn(DBTable t, ResultSet rs)
throws SQLException {
String name = rs.getString("COLUMN_NAME");
DataType empireType = getEmpireDataType(rs.getInt("DATA_TYPE"));
int colSize = rs.getInt("COLUMN_SIZE");
boolean required = false;
String defaultValue = rs.getString("COLUMN_DEF");
if (rs.getString("IS_NULLABLE").equalsIgnoreCase("NO"))
required = true;
// The following is a hack for MySQL which currently gets sent a string "CURRENT_TIMESTAMP" from the Empire-db driver for MySQL.
// This will avoid the driver problem because CURRENT_TIMESTAMP in the db will just do the current datetime.
// Essentially, Empire-db needs the concept of default values of one type that get mapped to another.
// In this case, MySQL "CURRENT_TIMESTAMP" for Types.TIMESTAMP needs to emit from the Empire-db driver the null value and not "CURRENT_TIMESTAMP".
if(rs.getInt("DATA_TYPE") == Types.TIMESTAMP && defaultValue != null && defaultValue.equals("CURRENT_TIMESTAMP")){
required = false; // It is in fact not required even though MySQL schema is required because it has a default value. Generally, should Empire-db emit (required && defaultValue != null) to truly determine if a column is required?
defaultValue = null; // If null (and required per schema?) MySQL will apply internal default value.
}
// AUTOINC indicator is not in java.sql.Types but rather meta data from DatabaseMetaData.getColumns()
// getEmpireDataType() above is not enough to support AUTOINC as it will only return DataType.INTEGER
DataType originalType = empireType;
ResultSetMetaData metaData = rs.getMetaData();
int colCount = metaData.getColumnCount();
String colName;
for (int i = 1; i <= colCount; i++) {
colName = metaData.getColumnName(i);