/**
* {@inheritDoc}
*/
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
Column column = super.readColumn(metaData, values);
if (column.getDefaultValue() != null)
{
if (column.getTypeCode() == Types.TIME)
{
PatternMatcher matcher = new Perl5Matcher();
// Db2 returns "HH24.MI.SS"
if (matcher.matches(column.getDefaultValue(), _db2TimePattern))
{
StringBuffer newDefault = new StringBuffer();
newDefault.append("'");
// the hour
newDefault.append(matcher.getMatch().group(1));
newDefault.append(":");
// the minute
newDefault.append(matcher.getMatch().group(2));
newDefault.append(":");
// the second
newDefault.append(matcher.getMatch().group(3));
newDefault.append("'");
column.setDefaultValue(newDefault.toString());
}
}
else if (column.getTypeCode() == Types.TIMESTAMP)
{
PatternMatcher matcher = new Perl5Matcher();
// Db2 returns "YYYY-MM-DD-HH24.MI.SS.FF"
if (matcher.matches(column.getDefaultValue(), _db2TimestampPattern))
{
StringBuffer newDefault = new StringBuffer();
newDefault.append("'");
// group 1 is the date which has the correct format
newDefault.append(matcher.getMatch().group(1));
newDefault.append(" ");
// the hour
newDefault.append(matcher.getMatch().group(2));
newDefault.append(":");
// the minute
newDefault.append(matcher.getMatch().group(3));
newDefault.append(":");
// the second
newDefault.append(matcher.getMatch().group(4));
// optionally, the fraction
if ((matcher.getMatch().groups() > 4) && (matcher.getMatch().group(4) != null))
{
newDefault.append(matcher.getMatch().group(5));
}
newDefault.append("'");
column.setDefaultValue(newDefault.toString());
}
}
else if (TypeMap.isTextType(column.getTypeCode()))
{
column.setDefaultValue(unescape(column.getDefaultValue(), "'", "''"));
}
}
return column;
}