Example usage for java.sql Types DOUBLE

List of usage examples for java.sql Types DOUBLE

Introduction

In this page you can find the example usage for java.sql Types DOUBLE.

Prototype

int DOUBLE

To view the source code for java.sql Types DOUBLE.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type DOUBLE.

Usage

From source file:com.squid.kraken.v4.caching.redis.datastruct.RawMatrix.java

public static String getJavaDatatype(int colType) {

    switch (colType) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return "java.lang.String";

    case Types.NUMERIC:
    case Types.DECIMAL:
        return "java.math.BigDecimal";

    case Types.BIT:
        return "boolean";

    case Types.TINYINT:
        return "byte";

    case Types.SMALLINT:
        return "short";

    case Types.INTEGER:
        return "int";

    case Types.BIGINT:
        return "long";

    case Types.REAL:
        return "float";

    case Types.FLOAT:
    case Types.DOUBLE:
        return "double";

    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        return "byte[]";

    case Types.DATE:
        return "java.sql.Date";

    case Types.TIME:
        return "java.sql.Time";

    case Types.TIMESTAMP:
        return "java.sql.Timestamp";

    case Types.OTHER:
        return "java.lang.Object";
    default:/*from  w w  w.  j a  va  2s  .  c  o  m*/
        return null;
    }
}

From source file:org.apache.ctakes.ytex.uima.mapper.DocumentMapperServiceImpl.java

/**
 * load mapping info//from   w  ww . j  a  v  a  2 s. com
 * 
 * @param type
 * @return
 */
private AnnoMappingInfo initMapInfo(final FeatureStructure fs) {
    final Type type = fs.getType();
    final String annoName = type.getShortName().toLowerCase();
    AnnoMappingInfo mapInfoTmp;
    final UimaType ut = uimaTypeMap.get(type.getName());
    if (this.mapAnnoMappingInfo.containsKey(type.getName())) {
        mapInfoTmp = this.mapAnnoMappingInfo.get(type.getName()).deepCopy();
    } else {
        mapInfoTmp = new AnnoMappingInfo();
    }
    final AnnoMappingInfo mapInfo = mapInfoTmp;
    if (ut != null)
        mapInfo.setUimaTypeId(ut.getUimaTypeID());
    // first see if the table name has been set in beans-uima.xml
    if (Strings.isNullOrEmpty(mapInfo.getTableName())) {
        // next see if the table name has been set in ref_uima_type
        if (ut != null && !Strings.isNullOrEmpty(ut.getTableName()))
            mapInfo.setTableName(ut.getTableName());
        else
            // default to anno_[short name]
            mapInfo.setTableName("anno_" + annoName);
    }
    final List<Feature> features = type.getFeatures();
    // get the non primitive fields
    for (Feature f : features) {
        if (f.getRange().isArray() && !f.getRange().getComponentType().isPrimitive()) {
            // add this field to the list of fields to store
            this.tl_mapFieldInfo.get().put(type.getName(), f.getShortName());
        }
    }
    this.sessionFactory.getCurrentSession().doWork(new Work() {
        @Override
        public void execute(Connection conn) throws SQLException {
            ResultSet rs = null;

            try {
                DatabaseMetaData dmd = conn.getMetaData();
                // get columns for corresponding table
                // mssql - add schema prefix
                // oracle - convert table name to upper case
                rs = dmd.getColumns(null, "mssql".equals(dbType) || "hsql".equals(dbType) ? dbSchema : null,
                        "orcl".equals(dbType) || "hsql".equals(dbType) ? mapInfo.getTableName().toUpperCase()
                                : mapInfo.getTableName(),
                        null);
                while (rs.next()) {
                    String colName = rs.getString("COLUMN_NAME");
                    int colSize = rs.getInt("COLUMN_SIZE");
                    int dataType = rs.getInt("DATA_TYPE");
                    if ("anno_base_id".equalsIgnoreCase(colName)) {
                        // skip anno_base_id
                        continue;
                    }
                    if ("uima_type_id".equalsIgnoreCase(colName)) {
                        // see if there is a uima_type_id column
                        // for FeatureStructures that are not annotations
                        // there can be a field for the uima_type_id
                        if (!(fs instanceof Annotation)
                                && Strings.isNullOrEmpty(mapInfo.getUimaTypeIdColumnName())) {
                            mapInfo.setUimaTypeIdColumnName(colName);
                        }
                    } else if ("coveredText".equalsIgnoreCase(colName)) {
                        // see if there is a coveredText column, store the
                        // covered
                        // text here
                        ColumnMappingInfo coveredTextColumn = new ColumnMappingInfo();
                        coveredTextColumn.setColumnName(colName);
                        mapInfo.setCoveredTextColumn(coveredTextColumn);
                        coveredTextColumn.setSize(colSize);
                    } else {
                        // possibility 1: the column is already mapped to
                        // the field
                        // if so, then just set the size
                        if (!updateSize(mapInfo, colName, colSize, dataType)) {
                            // possibility 2: the column is not mapped - see
                            // if
                            // it matches a field
                            // iterate through features, see which match the
                            // column
                            for (Feature f : features) {
                                String annoFieldName = f.getShortName();
                                if (f.getRange().isPrimitive() && annoFieldName.equalsIgnoreCase(colName)) {
                                    // primitive attribute
                                    ColumnMappingInfo fmap = new ColumnMappingInfo();
                                    fmap.setAnnoFieldName(annoFieldName);
                                    fmap.setColumnName(colName);
                                    fmap.setSize(colSize);
                                    fmap.setSqlType(dataType);
                                    mapInfo.getMapField().put(colName, fmap);
                                    break;
                                } else if (!f.getRange().isArray() && !f.getRange().isPrimitive()
                                        && annoFieldName.equalsIgnoreCase(colName)
                                        && (dataType == Types.INTEGER || dataType == Types.SMALLINT
                                                || dataType == Types.BIGINT || dataType == Types.NUMERIC
                                                || dataType == Types.FLOAT || dataType == Types.DOUBLE)) {
                                    // this feature is a reference to
                                    // another
                                    // annotation.
                                    // this column is numeric - a match
                                    ColumnMappingInfo fmap = new ColumnMappingInfo();
                                    fmap.setAnnoFieldName(annoFieldName);
                                    fmap.setColumnName(colName);
                                    fmap.setSize(colSize);
                                    fmap.setSqlType(dataType);
                                    mapInfo.getMapField().put(colName, fmap);
                                    break;
                                }
                            }
                        }
                    }
                }
            } finally {
                if (rs != null) {
                    try {
                        rs.close();
                    } catch (SQLException e) {
                    }
                }
            }
        }
    });
    // don't map this annotation if no fields match columns
    if (mapInfo.getMapField().size() == 0 && mapInfo.getCoveredTextColumn() == null
            && Strings.isNullOrEmpty(mapInfo.getUimaTypeIdColumnName()))
        return null;
    // generate sql
    StringBuilder b = new StringBuilder("insert into ");
    b.append(this.getTablePrefix()).append(mapInfo.getTableName());
    b.append("(anno_base_id");
    // add coveredText column if available
    if (mapInfo.getCoveredTextColumn() != null) {
        b.append(", coveredText");
    }
    // add uima_type_id column if available
    if (mapInfo.getUimaTypeIdColumnName() != null) {
        b.append(", uima_type_id");
    }
    // add other fields
    for (Map.Entry<String, ColumnMappingInfo> fieldEntry : mapInfo.getMapField().entrySet()) {
        b.append(", ").append(dialect.openQuote()).append(fieldEntry.getValue().getColumnName())
                .append(dialect.closeQuote());
    }
    b.append(") values (?");
    // add coveredText bind param
    if (mapInfo.getCoveredTextColumn() != null) {
        b.append(", ?");
    }
    // add uimaTypeId bind param
    if (mapInfo.getUimaTypeIdColumnName() != null) {
        b.append(", ?");
    }
    // add bind params for other fields
    b.append(Strings.repeat(", ?", mapInfo.getMapField().size())).append(")");
    mapInfo.setSql(b.toString());
    if (log.isInfoEnabled())
        log.info("sql insert for type " + type.getName() + ": " + mapInfo.getSql());
    if (log.isDebugEnabled())
        log.debug("initMapInfo(" + annoName + "): " + mapInfo);
    return mapInfo;
}

From source file:org.jumpmind.symmetric.db.ase.AseTriggerTemplate.java

@Override
protected String buildKeyVariablesDeclare(Column[] columns, String prefix) {
    String text = "";
    for (int i = 0; i < columns.length; i++) {
        text += "declare @" + prefix + "pk" + i + " ";
        switch (columns[i].getMappedTypeCode()) {
        case Types.TINYINT:
        case Types.SMALLINT:
        case Types.INTEGER:
        case Types.BIGINT:
            // ASE does not support bigint
            text += "NUMERIC(18,0)\n";
            break;
        case Types.NUMERIC:
        case Types.DECIMAL:
            // Use same default scale and precision used by Sybase ASA
            // for a decimal with unspecified scale and precision.
            text += "decimal(30,6)\n";
            break;
        case Types.FLOAT:
        case Types.REAL:
        case Types.DOUBLE:
            text += "float\n";
            break;
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGVARCHAR:
            text += "varchar(1000)\n";
            break;
        case Types.DATE:
            text += "date\n";
            break;
        case Types.TIME:
            text += "time\n";
            break;
        case Types.TIMESTAMP:
            text += "datetime\n";
            break;
        case Types.BOOLEAN:
        case Types.BIT:
            text += "bit\n";
            break;
        case Types.CLOB:
            text += "varchar(32767)\n";
            break;
        case Types.BLOB:
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
        case -10: // SQL-Server ntext binary type
            text += "varbinary(32767)\n";
            break;
        case Types.OTHER:
            text += "varbinary(32767)\n";
            break;
        default:/*from  w  w  w.  j a v a2 s.  co  m*/
            if (columns[i].getJdbcTypeName() != null
                    && columns[i].getJdbcTypeName().equalsIgnoreCase("interval")) {
                text += "interval";
                break;
            }
            throw new NotImplementedException(columns[i] + " is of type " + columns[i].getMappedType());
        }
    }

    return text;
}

From source file:org.openiot.gsn.storage.StorageManager.java

public void executeInsert(CharSequence tableName, DataField[] fields, StreamElement streamElement,
        Connection connection) throws SQLException {
    PreparedStatement ps = null;/*from  w ww. j ava 2s .  c  om*/
    String query = getStatementInsert(tableName, fields).toString();
    try {
        ps = connection.prepareStatement(query);
        int counter = 1;
        for (DataField dataField : fields) {
            if (dataField.getName().equalsIgnoreCase("timed"))
                continue;
            Serializable value = streamElement.getData(dataField.getName());

            switch (dataField.getDataTypeID()) {
            case DataTypes.VARCHAR:
                if (value == null)
                    ps.setNull(counter, Types.VARCHAR);
                else
                    ps.setString(counter, value.toString());
                break;
            case DataTypes.CHAR:
                if (value == null)
                    ps.setNull(counter, Types.CHAR);
                else
                    ps.setString(counter, value.toString());
                break;
            case DataTypes.INTEGER:
                if (value == null)
                    ps.setNull(counter, Types.INTEGER);
                else
                    ps.setInt(counter, ((Number) value).intValue());
                break;
            case DataTypes.SMALLINT:
                if (value == null)
                    ps.setNull(counter, Types.SMALLINT);
                else
                    ps.setShort(counter, ((Number) value).shortValue());
                break;
            case DataTypes.TINYINT:
                if (value == null)
                    ps.setNull(counter, Types.TINYINT);
                else
                    ps.setByte(counter, ((Number) value).byteValue());
                break;
            case DataTypes.DOUBLE:
                if (value == null)
                    ps.setNull(counter, Types.DOUBLE);
                else
                    ps.setDouble(counter, ((Number) value).doubleValue());
                break;
            case DataTypes.BIGINT:
                if (value == null)
                    ps.setNull(counter, Types.BIGINT);
                else
                    ps.setLong(counter, ((Number) value).longValue());
                break;
            case DataTypes.BINARY:
                if (value == null)
                    ps.setNull(counter, Types.BINARY);
                else
                    ps.setBytes(counter, (byte[]) value);
                break;
            default:
                logger.error("The type conversion is not supported for : " + dataField.getName() + "("
                        + dataField.getDataTypeID() + ") : ");
            }
            counter++;
        }
        ps.setLong(counter, streamElement.getTimeStamp());
        ps.execute();
    } catch (GSNRuntimeException e) {
        //if (e.getType() == GSNRuntimeException.UNEXPECTED_VIRTUAL_SENSOR_REMOVAL) {
        //    if (logger.isDebugEnabled())
        //        logger.debug("An stream element dropped due to unexpected virtual sensor removal. (Stream element: " + streamElement.toString() + ")+ Query: " + query, e);
        //} else
        logger.warn("Inserting a stream element failed : " + streamElement.toString(), e);
    } catch (SQLException e) {
        if (e.getMessage().toLowerCase().contains("duplicate entry"))
            logger.info("Error occurred on inserting data to the database, an stream element dropped due to: "
                    + e.getMessage() + ". (Stream element: " + streamElement.toString() + ")+ Query: " + query);
        else
            logger.warn("Error occurred on inserting data to the database, an stream element dropped due to: "
                    + e.getMessage() + ". (Stream element: " + streamElement.toString() + ")+ Query: " + query);
        throw e;
    } finally {
        close(ps);
    }
}

From source file:org.apache.ddlutils.io.TestDatabaseIO.java

/**
 * Tests a database model with a table with a column with a java name.
 *//*from   w  w  w.j  av a  2s .com*/
public void testColumnWithJavaName() throws Exception {
    Database model = readModel("<database xmlns='" + DatabaseIO.DDLUTILS_NAMESPACE + "' name='test'>\n"
            + "  <table name='SomeTable'\n" + "         description='Some table'>\n" + "    <column name='ID'\n"
            + "            type='DOUBLE'\n" + "            javaName='testString'/>\n" + "  </table>\n"
            + "</database>");

    assertEquals("test", model.getName());
    assertEquals(1, model.getTableCount());

    Table table = model.getTable(0);

    assertEquals("SomeTable", "Some table", 1, 0, 0, 0, 0, table);
    assertEquals("ID", Types.DOUBLE, 0, 0, null, null, "testString", false, false, false, table.getColumn(0));

    assertEquals("<?xml version='1.0' encoding='UTF-8'?>\n" + "<database xmlns=\""
            + DatabaseIO.DDLUTILS_NAMESPACE + "\" name=\"test\">\n"
            + "  <table name=\"SomeTable\" description=\"Some table\">\n"
            + "    <column name=\"ID\" primaryKey=\"false\" required=\"false\" type=\"DOUBLE\" autoIncrement=\"false\" javaName=\"testString\" />\n"
            + "  </table>\n" + "</database>\n", model);
}

From source file:tinygsn.storage.StorageManager.java

public void executeInsert(CharSequence tableName, DataField[] fields, StreamElement streamElement,
        Connection connection) throws SQLException {
    PreparedStatement ps = null;/*from  www  . j av a  2  s  . com*/
    String query = getStatementInsert(tableName, fields).toString();
    try {
        ps = connection.prepareStatement(query);
        int counter = 1;
        for (DataField dataField : fields) {
            if (dataField.getName().equalsIgnoreCase("timed"))
                continue;
            Serializable value = streamElement.getData(dataField.getName());

            switch (dataField.getDataTypeID()) {
            case DataTypes.VARCHAR:
                if (value == null)
                    ps.setNull(counter, Types.VARCHAR);
                else
                    ps.setString(counter, value.toString());
                break;
            case DataTypes.CHAR:
                if (value == null)
                    ps.setNull(counter, Types.CHAR);
                else
                    ps.setString(counter, value.toString());
                break;
            case DataTypes.INTEGER:
                if (value == null)
                    ps.setNull(counter, Types.INTEGER);
                else
                    ps.setInt(counter, ((Number) value).intValue());
                break;
            case DataTypes.SMALLINT:
                if (value == null)
                    ps.setNull(counter, Types.SMALLINT);
                else
                    ps.setShort(counter, ((Number) value).shortValue());
                break;
            case DataTypes.TINYINT:
                if (value == null)
                    ps.setNull(counter, Types.TINYINT);
                else
                    ps.setByte(counter, ((Number) value).byteValue());
                break;
            case DataTypes.DOUBLE:
                if (value == null)
                    ps.setNull(counter, Types.DOUBLE);
                else
                    ps.setDouble(counter, ((Number) value).doubleValue());
                break;
            case DataTypes.BIGINT:
                if (value == null)
                    ps.setNull(counter, Types.BIGINT);
                else
                    ps.setLong(counter, ((Number) value).longValue());
                break;
            case DataTypes.BINARY:
                if (value == null)
                    ps.setNull(counter, Types.BINARY);
                else
                    ps.setBytes(counter, (byte[]) value);
                break;
            default:
                // logger.error("The type conversion is not supported for : "
                // + dataField.getName() + "(" + dataField.getDataTypeID() + ") : ");
            }
            counter++;
        }
        ps.setLong(counter, streamElement.getTimeStamp());
        ps.execute();
    } catch (GSNRuntimeException e) {
        // if (e.getType() ==
        // GSNRuntimeException.UNEXPECTED_VIRTUAL_SENSOR_REMOVAL) {
        // if (logger.isDebugEnabled())
        //
        // logger
        // .debug(
        // "An stream element dropped due to unexpected virtual sensor removal. (Stream element: "
        // + streamElement.toString() + ")+ Query: " + query, e);
        // } else
        // logger.warn(
        // "Inserting a stream element failed : " + streamElement.toString(), e);
    } catch (SQLException e) {
        if (e.getMessage().toLowerCase().contains("duplicate entry"))
            // logger
            // .info("Error occurred on inserting data to the database, an stream element dropped due to: "
            // + e.getMessage()
            // + ". (Stream element: "
            // + streamElement.toString() + ")+ Query: " + query);
            // else
            // logger
            // .warn("Error occurred on inserting data to the database, an stream element dropped due to: "
            // + e.getMessage()
            // + ". (Stream element: "
            // + streamElement.toString() + ")+ Query: " + query);
            throw e;
    } finally {
        close(ps);
    }
}

From source file:com.squid.kraken.v4.caching.redis.datastruct.RawMatrix.java

public static boolean isPrimitiveType(int colType) {

    switch (colType) {

    case Types.BIT:
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
    case Types.BIGINT:
    case Types.REAL:
    case Types.FLOAT:
    case Types.DOUBLE:
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        return true;

    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    case Types.NUMERIC:
    case Types.DECIMAL:
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        return false;

    default://from  www  . j a  va  2  s  .c  o  m
        return false;
    }
}

From source file:io.bibleget.BibleGetDB.java

private void listColNamesTypes(DatabaseMetaData dbMeta, ResultSet rs) {
    //System.out.println("After Table Creation: Table "+rs.getString("TABLE_NAME")+" exists !!");
    ResultSet cols;/*from   w w w .  j a v a 2  s  . c om*/
    try {
        cols = dbMeta.getColumns(null, null, rs.getString("TABLE_NAME"), null);
        while (cols.next()) {
            //System.out.println(cols.getString("COLUMN_NAME"));
            colNames.add(cols.getString("COLUMN_NAME"));
            int dType = cols.getInt("DATA_TYPE");
            switch (dType) {
            case Types.VARCHAR:
                colDataTypes.add(String.class);
                break;
            case Types.INTEGER:
                colDataTypes.add(Integer.class);
                break;
            case Types.FLOAT:
                colDataTypes.add(Float.class);
                break;
            case Types.DOUBLE:
            case Types.REAL:
                colDataTypes.add(Double.class);
                break;
            case Types.DATE:
            case Types.TIME:
            case Types.TIMESTAMP:
                colDataTypes.add(java.sql.Date.class);
                break;
            case Types.BOOLEAN:
                colDataTypes.add(Boolean.class);
                break;
            default:
                colDataTypes.add(String.class);
                break;
            }
        }
    } catch (SQLException ex) {
        Logger.getLogger(BibleGetDB.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:gsn.storage.StorageManager.java

public void executeInsert(CharSequence tableName, DataField[] fields, StreamElement streamElement,
        Connection connection) throws SQLException {
    PreparedStatement ps = null;/*  w w  w . jav  a  2s. c  o m*/
    String query = getStatementInsert(tableName, fields).toString();
    try {
        ps = connection.prepareStatement(query);
        int counter = 1;
        for (DataField dataField : fields) {
            if (dataField.getName().equalsIgnoreCase("timed"))
                continue;
            Serializable value = streamElement.getData(dataField.getName());

            switch (dataField.getDataTypeID()) {
            case DataTypes.VARCHAR:
                if (value == null)
                    ps.setNull(counter, Types.VARCHAR);
                else
                    ps.setString(counter, value.toString());
                break;
            case DataTypes.CHAR:
                if (value == null)
                    ps.setNull(counter, Types.CHAR);
                else
                    ps.setString(counter, value.toString());
                break;
            case DataTypes.INTEGER:
                if (value == null)
                    ps.setNull(counter, Types.INTEGER);
                else
                    ps.setInt(counter, ((Number) value).intValue());
                break;
            case DataTypes.SMALLINT:
                if (value == null)
                    ps.setNull(counter, Types.SMALLINT);
                else
                    ps.setShort(counter, ((Number) value).shortValue());
                break;
            case DataTypes.TINYINT:
                if (value == null)
                    ps.setNull(counter, Types.TINYINT);
                else
                    ps.setByte(counter, ((Number) value).byteValue());
                break;
            case DataTypes.DOUBLE:
                if (value == null)
                    ps.setNull(counter, Types.DOUBLE);
                else
                    ps.setDouble(counter, ((Number) value).doubleValue());
                break;
            case DataTypes.FLOAT:
                if (value == null)
                    ps.setNull(counter, Types.FLOAT);
                else
                    ps.setFloat(counter, ((Number) value).floatValue());
                break;
            case DataTypes.BIGINT:
                if (value == null)
                    ps.setNull(counter, Types.BIGINT);
                else
                    ps.setLong(counter, ((Number) value).longValue());
                break;
            case DataTypes.BINARY:
                if (value == null)
                    ps.setNull(counter, Types.BINARY);
                else
                    ps.setBytes(counter, (byte[]) value);
                break;
            default:
                logger.error("The type conversion is not supported for : " + dataField.getName() + "("
                        + dataField.getDataTypeID() + ") : ");
            }
            counter++;
        }
        ps.setLong(counter, streamElement.getTimeStamp());
        ps.execute();
    } catch (GSNRuntimeException e) {
        //if (e.getType() == GSNRuntimeException.UNEXPECTED_VIRTUAL_SENSOR_REMOVAL) {
        //    if (logger.isDebugEnabled())
        //        logger.debug("An stream element dropped due to unexpected virtual sensor removal. (Stream element: " + streamElement.toString() + ")+ Query: " + query, e);
        //} else
        logger.warn("Inserting a stream element failed : " + streamElement.toString(), e);
    } catch (SQLException e) {
        if (e.getMessage().toLowerCase().contains("duplicate entry"))
            logger.info("Error occurred on inserting data to the database, an stream element dropped due to: "
                    + e.getMessage() + ". (Stream element: " + streamElement.toString() + ")+ Query: " + query);
        else
            logger.warn("Error occurred on inserting data to the database, an stream element dropped due to: "
                    + e.getMessage() + ". (Stream element: " + streamElement.toString() + ")+ Query: " + query);
        throw e;
    } finally {
        close(ps);
    }
}

From source file:org.apache.ddlutils.TestAgainstLiveDatabaseBase.java

/**
 * Returns a copy of the given model adjusted for type changes because of the native type mappings
 * which when read back from the database will map to different types.
 * /*from  www . j a va2s .  c om*/
 * @param sourceModel The source model
 * @return The adjusted model
 */
protected Database adjustModel(Database sourceModel) {
    Database model = new CloneHelper().clone(sourceModel);

    for (int tableIdx = 0; tableIdx < model.getTableCount(); tableIdx++) {
        Table table = model.getTable(tableIdx);

        for (int columnIdx = 0; columnIdx < table.getColumnCount(); columnIdx++) {
            Column column = table.getColumn(columnIdx);
            int origType = column.getTypeCode();
            int targetType = getPlatformInfo().getTargetJdbcType(origType);

            // we adjust the column types if the native type would back-map to a
            // different jdbc type
            if (targetType != origType) {
                column.setTypeCode(targetType);
                // we should also adapt the default value
                if (column.getDefaultValue() != null) {
                    DefaultValueHelper helper = getPlatform().getSqlBuilder().getDefaultValueHelper();

                    column.setDefaultValue(helper.convert(column.getDefaultValue(), origType, targetType));
                }
            }
            // we also promote the default size if the column has no size
            // spec of its own
            if ((column.getSize() == null) && getPlatformInfo().hasSize(targetType)) {
                Integer defaultSize = getPlatformInfo().getDefaultSize(targetType);

                if (defaultSize != null) {
                    column.setSize(defaultSize.toString());
                }
            }
            // finally the platform might return a synthetic default value if the column
            // is a primary key column
            if (getPlatformInfo().isSyntheticDefaultValueForRequiredReturned()
                    && (column.getDefaultValue() == null) && column.isRequired() && !column.isAutoIncrement()) {
                switch (column.getTypeCode()) {
                case Types.TINYINT:
                case Types.SMALLINT:
                case Types.INTEGER:
                case Types.BIGINT:
                    column.setDefaultValue("0");
                    break;
                case Types.REAL:
                case Types.FLOAT:
                case Types.DOUBLE:
                    column.setDefaultValue("0.0");
                    break;
                case Types.BIT:
                    column.setDefaultValue("false");
                    break;
                default:
                    column.setDefaultValue("");
                    break;
                }
            }
            if (column.isPrimaryKey() && getPlatformInfo().isPrimaryKeyColumnAutomaticallyRequired()) {
                column.setRequired(true);
            }
            if (column.isAutoIncrement() && getPlatformInfo().isIdentityColumnAutomaticallyRequired()) {
                column.setRequired(true);
            }
        }
        // we also add the default names to foreign keys that are initially unnamed
        for (int fkIdx = 0; fkIdx < table.getForeignKeyCount(); fkIdx++) {
            ForeignKey fk = table.getForeignKey(fkIdx);

            if (fk.getName() == null) {
                fk.setName(getPlatform().getSqlBuilder().getForeignKeyName(table, fk));
            }
        }
    }
    return model;
}