protected DataType readDataType(CachedRow columnMetadataResultSet, Column column, Database database) throws DatabaseException {

        if (database instanceof OracleDatabase) {
            String dataType = columnMetadataResultSet.getString("DATA_TYPE_NAME");
            dataType = dataType.replace("VARCHAR2", "VARCHAR");
            dataType = dataType.replace("NVARCHAR2", "NVARCHAR");

            DataType type = new DataType(dataType);
            type.setDataTypeId(columnMetadataResultSet.getInt("DATA_TYPE"));
            if (dataType.equalsIgnoreCase("NUMBER")) {
                type.setColumnSize(columnMetadataResultSet.getInt("DATA_PRECISION"));
//                if (type.getColumnSize() == null) {
//                    type.setColumnSize(38);
//                }
                type.setDecimalDigits(columnMetadataResultSet.getInt("DATA_SCALE"));
//                if (type.getDecimalDigits() == null) {
//                    type.setDecimalDigits(0);
//                }
//            type.setRadix(10);
            } else {
                type.setColumnSize(columnMetadataResultSet.getInt("DATA_LENGTH"));

                boolean isTimeStampDataType = dataType.toUpperCase().contains("TIMESTAMP");

                if (isTimeStampDataType || dataType.equalsIgnoreCase("NCLOB") || dataType.equalsIgnoreCase("BLOB") || dataType.equalsIgnoreCase("CLOB")) {
                    type.setColumnSize(null);
                } else if (dataType.equalsIgnoreCase("NVARCHAR") || dataType.equalsIgnoreCase("NCHAR")) {
                    type.setColumnSize(columnMetadataResultSet.getInt("CHAR_LENGTH"));
                    type.setColumnSizeUnit(DataType.ColumnSizeUnit.CHAR);
                } else {
                    String charUsed = columnMetadataResultSet.getString("CHAR_USED");
                    DataType.ColumnSizeUnit unit = null;
                    if ("C".equals(charUsed)) {
                        unit = DataType.ColumnSizeUnit.CHAR;
                        type.setColumnSize(columnMetadataResultSet.getInt("CHAR_LENGTH"));
                    } else if ("B".equals(charUsed)) {
                        unit = DataType.ColumnSizeUnit.BYTE;
                    }
                    type.setColumnSizeUnit(unit);
                }
            }


            return type;
        }

        String columnTypeName = (String) columnMetadataResultSet.get("TYPE_NAME");

        if (database instanceof MSSQLDatabase) {
            if ("numeric() identity".equalsIgnoreCase(columnTypeName)) {
                columnTypeName = "numeric";
            } else if ("decimal() identity".equalsIgnoreCase(columnTypeName)) {
                columnTypeName = "decimal";
            } else if ("xml".equalsIgnoreCase(columnTypeName)) {
                columnMetadataResultSet.set("COLUMN_SIZE", null);
                columnMetadataResultSet.set("DECIMAL_DIGITS", null);
            } else if ("datetimeoffset".equalsIgnoreCase(columnTypeName)
                || "time".equalsIgnoreCase(columnTypeName)) {
                columnMetadataResultSet.set("COLUMN_SIZE", columnMetadataResultSet.getInt("DECIMAL_DIGITS"));
                columnMetadataResultSet.set("DECIMAL_DIGITS", null);
            }
        }

        if (database instanceof FirebirdDatabase) {
            if ("BLOB SUB_TYPE 0".equals(columnTypeName)) {
                columnTypeName = "BLOB";
            }
            if ("BLOB SUB_TYPE 1".equals(columnTypeName)) {
                columnTypeName = "CLOB";
            }
        }

        if ((database instanceof MySQLDatabase) && ("ENUM".equalsIgnoreCase(columnTypeName) || "SET".equalsIgnoreCase
            (columnTypeName))) {
            try {
                String boilerLength;
                if ("ENUM".equalsIgnoreCase(columnTypeName)) {
                    boilerLength = "7";
                } else  {
                    // SET
                    boilerLength = "6";
                }
                List<String> enumValues = ExecutorService.getInstance().getExecutor(database).queryForList(
                    new RawSqlStatement(
                        "SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING(COLUMN_TYPE, " + boilerLength +
                            ", LENGTH(COLUMN_TYPE) - " + boilerLength +
                            " - 1 ), \"','\", 1 + units.i + tens.i * 10) , \"','\", -1)\n" +
                            "FROM INFORMATION_SCHEMA.COLUMNS\n" +
                            "CROSS JOIN (SELECT 0 AS i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 " +
                            "UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) units\n" +
                            "CROSS JOIN (SELECT 0 AS i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 " +
                            "UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) tens\n" +
                            "WHERE TABLE_NAME = '" + column.getRelation().getName() + "' \n" +
                            "AND COLUMN_NAME = '" + column.getName() + "'"), String.class);
                String enumClause = "";
                for (String enumValue : enumValues) {
                    enumClause += "'" + enumValue + "', ";
                }
                enumClause = enumClause.replaceFirst(", $", "");
                return new DataType(columnTypeName + "(" + enumClause + ")");
            } catch (DatabaseException e) {
                Scope.getCurrentScope().getLog(getClass()).warning(LogType.LOG, "Error fetching enum values", e);
            }
        }

        DataType.ColumnSizeUnit columnSizeUnit = DataType.ColumnSizeUnit.BYTE;

        int dataType = columnMetadataResultSet.getInt("DATA_TYPE");
        Integer columnSize = null;
        Integer decimalDigits = null;

        if (!database.dataTypeIsNotModifiable(columnTypeName)) {
            // don't set size for types like int4, int8 etc
            columnSize = columnMetadataResultSet.getInt("COLUMN_SIZE");
            decimalDigits = columnMetadataResultSet.getInt("DECIMAL_DIGITS");
            if ((decimalDigits != null) && decimalDigits.equals(0)) {
                decimalDigits = null;
            }
        }

        Integer radix = columnMetadataResultSet.getInt("NUM_PREC_RADIX");

        Integer characterOctetLength = columnMetadataResultSet.getInt("CHAR_OCTET_LENGTH");

        if (database instanceof AbstractDb2Database) {
            String typeName = columnMetadataResultSet.getString("TYPE_NAME");
            if (("DBCLOB".equalsIgnoreCase(typeName) || "GRAPHIC".equalsIgnoreCase(typeName)
                || "VARGRAPHIC".equalsIgnoreCase(typeName)) &&(columnSize != null)) {
                //Stored as double length chars
                columnSize = columnSize / 2;
            }
            if ("TIMESTAMP".equalsIgnoreCase(columnTypeName) && (decimalDigits == null)) {
                // Actually a date
                columnTypeName = "DATE";
                dataType = Types.DATE;
            }
        }

        if ((database instanceof PostgresDatabase) && (columnSize != null) && columnSize.equals(Integer.MAX_VALUE)) {
            columnSize = null;
        }

        // For SAP (Sybase) SQL ANywhere, JDBC returns "LONG(2147483647) binary" (the number is 2^31-1)
        // but when creating a column, LONG BINARY must not have parameters.
        // The same applies to LONG(...) VARCHAR.
        if (database instanceof SybaseASADatabase
            && ("LONG BINARY".equalsIgnoreCase(columnTypeName) || "LONG VARCHAR".equalsIgnoreCase(columnTypeName))) {
            columnSize = null;
        }

        DataType type = new DataType(columnTypeName);
        type.setDataTypeId(dataType);

        /*
         * According to the description of DatabaseMetaData.getColumns, the content of the "COLUMN_SIZE" column is
         * pretty worthless for datetime/timestamp columns:
         *
         * "For datetime datatypes, this is the length in characters of the String representation
         * (assuming the maximum allowed precision of the fractional seconds component)."
         * In the case of TIMESTAMP columns, the information we are really looking for
         * (the fractional digits) is located in the column DECIMAL_DIGITS.
         */
        int jdbcType = columnMetadataResultSet.getInt("DATA_TYPE");

        // Java 8 compatibility notes: When upgrading this project to JDK8 and beyond, also execute this if-branch
        // if jdbcType is TIMESTAMP_WITH_TIMEZONE (does not exist yet in JDK7)
        if (jdbcType == Types.TIMESTAMP) {

            if (decimalDigits == null) {
                type.setColumnSize(null);
            } else {
                type.setColumnSize((decimalDigits != database.getDefaultFractionalDigitsForTimestamp()) ?
                    decimalDigits : null
                );
            }

            type.setDecimalDigits(null);
        } else {
            type.setColumnSize(columnSize);
            type.setDecimalDigits(decimalDigits);
        }
        type.setRadix(radix);
        type.setCharacterOctetLength(characterOctetLength);
        type.setColumnSizeUnit(columnSizeUnit);


        return type;
    }
protected DataType readDataType(CachedRow columnMetadataResultSet, Column column, Database database) throws DatabaseException {

        if (database instanceof OracleDatabase) {
            String dataType = columnMetadataResultSet.getString("DATA_TYPE_NAME");
            dataType = dataType.replace("VARCHAR2", "VARCHAR");
            dataType = dataType.replace("NVARCHAR2", "NVARCHAR");

            DataType type = new DataType(dataType);
            type.setDataTypeId(columnMetadataResultSet.getInt("DATA_TYPE"));
            if (dataType.equalsIgnoreCase("NUMBER")) {
                type.setColumnSize(columnMetadataResultSet.getInt("DATA_PRECISION"));



                type.setDecimalDigits(columnMetadataResultSet.getInt("DATA_SCALE"));




            } else {
                type.setColumnSize(columnMetadataResultSet.getInt("DATA_LENGTH"));

                boolean isTimeStampDataType = dataType.toUpperCase().contains("TIMESTAMP");

                if (isTimeStampDataType || dataType.equalsIgnoreCase("NCLOB") || dataType.equalsIgnoreCase("BLOB") || dataType.equalsIgnoreCase("CLOB")) {
                    type.setColumnSize(null);
                } else if (dataType.equalsIgnoreCase("NVARCHAR") || dataType.equalsIgnoreCase("NCHAR")) {
                    type.setColumnSize(columnMetadataResultSet.getInt("CHAR_LENGTH"));
                    type.setColumnSizeUnit(DataType.ColumnSizeUnit.CHAR);
                } else {
                    String charUsed = columnMetadataResultSet.getString("CHAR_USED");
                    DataType.ColumnSizeUnit unit = null;
                    if ("C".equals(charUsed)) {
                        unit = DataType.ColumnSizeUnit.CHAR;
                        type.setColumnSize(columnMetadataResultSet.getInt("CHAR_LENGTH"));
                    } else if ("B".equals(charUsed)) {
                        unit = DataType.ColumnSizeUnit.BYTE;
                    }
                    type.setColumnSizeUnit(unit);
                }
            }


            return type;
        }

        String columnTypeName = (String) columnMetadataResultSet.get("TYPE_NAME");

        if (database instanceof MSSQLDatabase) {
            if ("numeric() identity".equalsIgnoreCase(columnTypeName)) {
                columnTypeName = "numeric";
            } else if ("decimal() identity".equalsIgnoreCase(columnTypeName)) {
                columnTypeName = "decimal";
            } else if ("xml".equalsIgnoreCase(columnTypeName)) {
                columnMetadataResultSet.set("COLUMN_SIZE", null);
                columnMetadataResultSet.set("DECIMAL_DIGITS", null);
            } else if ("datetimeoffset".equalsIgnoreCase(columnTypeName)
                || "time".equalsIgnoreCase(columnTypeName)) {
                columnMetadataResultSet.set("COLUMN_SIZE", columnMetadataResultSet.getInt("DECIMAL_DIGITS"));
                columnMetadataResultSet.set("DECIMAL_DIGITS", null);
            }
        }

        if (database instanceof FirebirdDatabase) {
            if ("BLOB SUB_TYPE 0".equals(columnTypeName)) {
                columnTypeName = "BLOB";
            }
            if ("BLOB SUB_TYPE 1".equals(columnTypeName)) {
                columnTypeName = "CLOB";
            }
        }

        if ((database instanceof MySQLDatabase) && ("ENUM".equalsIgnoreCase(columnTypeName) || "SET".equalsIgnoreCase
            (columnTypeName))) {
            try {
                String boilerLength;
                if ("ENUM".equalsIgnoreCase(columnTypeName)) {
                    boilerLength = "7";
                } else  {
                    
                    boilerLength = "6";
                }
                List<String> enumValues = ExecutorService.getInstance().getExecutor(database).queryForList(
                    new RawSqlStatement(
                        "SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING(COLUMN_TYPE, " + boilerLength +
                            ", LENGTH(COLUMN_TYPE) - " + boilerLength +
                            " - 1 ), \"','\", 1 + units.i + tens.i * 10) , \"','\", -1)\n" +
                            "FROM INFORMATION_SCHEMA.COLUMNS\n" +
                            "CROSS JOIN (SELECT 0 AS i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 " +
                            "UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) units\n" +
                            "CROSS JOIN (SELECT 0 AS i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 " +
                            "UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) tens\n" +
                            "WHERE TABLE_NAME = '" + column.getRelation().getName() + "' \n" +
                            "AND COLUMN_NAME = '" + column.getName() + "'"), String.class);
                String enumClause = "";
                for (String enumValue : enumValues) {
                    enumClause += "'" + enumValue + "', ";
                }
                enumClause = enumClause.replaceFirst(", $", "");
                return new DataType(columnTypeName + "(" + enumClause + ")");
            } catch (DatabaseException e) {
                Scope.getCurrentScope().getLog(getClass()).warning(LogType.LOG, "Error fetching enum values", e);
            }
        }

        DataType.ColumnSizeUnit columnSizeUnit = DataType.ColumnSizeUnit.BYTE;

        int dataType = columnMetadataResultSet.getInt("DATA_TYPE");
        Integer columnSize = null;
        Integer decimalDigits = null;

        if (!database.dataTypeIsNotModifiable(columnTypeName)) {
            
            columnSize = columnMetadataResultSet.getInt("COLUMN_SIZE");
            decimalDigits = columnMetadataResultSet.getInt("DECIMAL_DIGITS");
            if ((decimalDigits != null) && decimalDigits.equals(0)) {
                decimalDigits = null;
            }
        }

        Integer radix = columnMetadataResultSet.getInt("NUM_PREC_RADIX");

        Integer characterOctetLength = columnMetadataResultSet.getInt("CHAR_OCTET_LENGTH");

        if (database instanceof AbstractDb2Database) {
            String typeName = columnMetadataResultSet.getString("TYPE_NAME");
            if (("DBCLOB".equalsIgnoreCase(typeName) || "GRAPHIC".equalsIgnoreCase(typeName)
                || "VARGRAPHIC".equalsIgnoreCase(typeName)) &&(columnSize != null)) {
                
                columnSize = columnSize / 2;
            }
            if ("TIMESTAMP".equalsIgnoreCase(columnTypeName) && (decimalDigits == null)) {
                
                columnTypeName = "DATE";
                dataType = Types.DATE;
            }
        }

        if ((database instanceof PostgresDatabase) && (columnSize != null) && columnSize.equals(Integer.MAX_VALUE)) {
            columnSize = null;
        }

        
        
        
        if (database instanceof SybaseASADatabase
            && ("LONG BINARY".equalsIgnoreCase(columnTypeName) || "LONG VARCHAR".equalsIgnoreCase(columnTypeName))) {
            columnSize = null;
        }

        DataType type = new DataType(columnTypeName);
        type.setDataTypeId(dataType);

        
        int jdbcType = columnMetadataResultSet.getInt("DATA_TYPE");

        
        
        if (jdbcType == Types.TIMESTAMP) {

            if (decimalDigits == null) {
                type.setColumnSize(null);
            } else {
                type.setColumnSize((decimalDigits != database.getDefaultFractionalDigitsForTimestamp()) ?
                    decimalDigits : null
                );
            }

            type.setDecimalDigits(null);
        } else {
            type.setColumnSize(columnSize);
            type.setDecimalDigits(decimalDigits);
        }
        type.setRadix(radix);
        type.setCharacterOctetLength(characterOctetLength);
        type.setColumnSizeUnit(columnSizeUnit);


        return type;
    }
protected DataType readDataType ( CachedRow columnMetadataResultSet , Column column , Database database ) throws DatabaseException { if ( database instanceof OracleDatabase ) { String dataType = columnMetadataResultSet . getString ( "DATA_TYPE_NAME" ) ; dataType = dataType . replace ( "VARCHAR2" , "VARCHAR" ) ; dataType = dataType . replace ( "NVARCHAR2" , "NVARCHAR" ) ; DataType type = new DataType ( dataType ) ; type . setDataTypeId ( columnMetadataResultSet . getInt ( "DATA_TYPE" ) ) ; if ( dataType . equalsIgnoreCase ( "NUMBER" ) ) { type . setColumnSize ( columnMetadataResultSet . getInt ( "DATA_PRECISION" ) ) ; //                if (type.getColumnSize() == null) { //                    type.setColumnSize(38); //                } type . setDecimalDigits ( columnMetadataResultSet . getInt ( "DATA_SCALE" ) ) ; //                if (type.getDecimalDigits() == null) { //                    type.setDecimalDigits(0); //                } //            type.setRadix(10); } else { type . setColumnSize ( columnMetadataResultSet . getInt ( "DATA_LENGTH" ) ) ; boolean isTimeStampDataType = dataType . toUpperCase ( ) . contains ( "TIMESTAMP" ) ; if ( isTimeStampDataType || dataType . equalsIgnoreCase ( "NCLOB" ) || dataType . equalsIgnoreCase ( "BLOB" ) || dataType . equalsIgnoreCase ( "CLOB" ) ) { type . setColumnSize ( null ) ; } else if ( dataType . equalsIgnoreCase ( "NVARCHAR" ) || dataType . equalsIgnoreCase ( "NCHAR" ) ) { type . setColumnSize ( columnMetadataResultSet . getInt ( "CHAR_LENGTH" ) ) ; type . setColumnSizeUnit ( DataType . ColumnSizeUnit . CHAR ) ; } else { String charUsed = columnMetadataResultSet . getString ( "CHAR_USED" ) ; DataType . ColumnSizeUnit unit = null ; if ( "C" . equals ( charUsed ) ) { unit = DataType . ColumnSizeUnit . CHAR ; type . setColumnSize ( columnMetadataResultSet . getInt ( "CHAR_LENGTH" ) ) ; } else if ( "B" . equals ( charUsed ) ) { unit = DataType . ColumnSizeUnit . BYTE ; } type . setColumnSizeUnit ( unit ) ; } } return type ; } String columnTypeName = ( String ) columnMetadataResultSet . get ( "TYPE_NAME" ) ; if ( database instanceof MSSQLDatabase ) { if ( "numeric() identity" . equalsIgnoreCase ( columnTypeName ) ) { columnTypeName = "numeric" ; } else if ( "decimal() identity" . equalsIgnoreCase ( columnTypeName ) ) { columnTypeName = "decimal" ; } else if ( "xml" . equalsIgnoreCase ( columnTypeName ) ) { columnMetadataResultSet . set ( "COLUMN_SIZE" , null ) ; columnMetadataResultSet . set ( "DECIMAL_DIGITS" , null ) ; } else if ( "datetimeoffset" . equalsIgnoreCase ( columnTypeName ) || "time" . equalsIgnoreCase ( columnTypeName ) ) { columnMetadataResultSet . set ( "COLUMN_SIZE" , columnMetadataResultSet . getInt ( "DECIMAL_DIGITS" ) ) ; columnMetadataResultSet . set ( "DECIMAL_DIGITS" , null ) ; } } if ( database instanceof FirebirdDatabase ) { if ( "BLOB SUB_TYPE 0" . equals ( columnTypeName ) ) { columnTypeName = "BLOB" ; } if ( "BLOB SUB_TYPE 1" . equals ( columnTypeName ) ) { columnTypeName = "CLOB" ; } } if ( ( database instanceof MySQLDatabase ) && ( "ENUM" . equalsIgnoreCase ( columnTypeName ) || "SET" . equalsIgnoreCase ( columnTypeName ) ) ) { try { String boilerLength ; if ( "ENUM" . equalsIgnoreCase ( columnTypeName ) ) { boilerLength = "7" ; } else { // SET boilerLength = "6" ; } List < String > enumValues = ExecutorService . getInstance ( ) . getExecutor ( database ) . queryForList ( new RawSqlStatement ( "SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING(COLUMN_TYPE, " + boilerLength + ", LENGTH(COLUMN_TYPE) - " + boilerLength + " - 1 ), \"','\", 1 + units.i + tens.i * 10) , \"','\", -1)\n" + "FROM INFORMATION_SCHEMA.COLUMNS\n" + "CROSS JOIN (SELECT 0 AS i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 " + "UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) units\n" + "CROSS JOIN (SELECT 0 AS i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 " + "UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) tens\n" + "WHERE TABLE_NAME = '" + column . getRelation ( ) . getName ( ) + "' \n" + "AND COLUMN_NAME = '" + column . getName ( ) + "'" ) , String . class ) ; String enumClause = "" ; for ( String enumValue : enumValues ) { enumClause += "'" + enumValue + "', " ; } enumClause = enumClause . replaceFirst ( ", $" , "" ) ; return new DataType ( columnTypeName + "(" + enumClause + ")" ) ; } catch ( DatabaseException e ) { Scope . getCurrentScope ( ) . getLog ( getClass ( ) ) . warning ( LogType . LOG , "Error fetching enum values" , e ) ; } } DataType . ColumnSizeUnit columnSizeUnit = DataType . ColumnSizeUnit . BYTE ; int dataType = columnMetadataResultSet . getInt ( "DATA_TYPE" ) ; Integer columnSize = null ; Integer decimalDigits = null ; if ( ! database . dataTypeIsNotModifiable ( columnTypeName ) ) { // don't set size for types like int4, int8 etc columnSize = columnMetadataResultSet . getInt ( "COLUMN_SIZE" ) ; decimalDigits = columnMetadataResultSet . getInt ( "DECIMAL_DIGITS" ) ; if ( ( decimalDigits != null ) && decimalDigits . equals ( 0 ) ) { decimalDigits = null ; } } Integer radix = columnMetadataResultSet . getInt ( "NUM_PREC_RADIX" ) ; Integer characterOctetLength = columnMetadataResultSet . getInt ( "CHAR_OCTET_LENGTH" ) ; if ( database instanceof AbstractDb2Database ) { String typeName = columnMetadataResultSet . getString ( "TYPE_NAME" ) ; if ( ( "DBCLOB" . equalsIgnoreCase ( typeName ) || "GRAPHIC" . equalsIgnoreCase ( typeName ) || "VARGRAPHIC" . equalsIgnoreCase ( typeName ) ) && ( columnSize != null ) ) { //Stored as double length chars columnSize = columnSize / 2 ; } if ( "TIMESTAMP" . equalsIgnoreCase ( columnTypeName ) && ( decimalDigits == null ) ) { // Actually a date columnTypeName = "DATE" ; dataType = Types . DATE ; } } if ( ( database instanceof PostgresDatabase ) && ( columnSize != null ) && columnSize . equals ( Integer . MAX_VALUE ) ) { columnSize = null ; } // For SAP (Sybase) SQL ANywhere, JDBC returns "LONG(2147483647) binary" (the number is 2^31-1) // but when creating a column, LONG BINARY must not have parameters. // The same applies to LONG(...) VARCHAR. if ( database instanceof SybaseASADatabase && ( "LONG BINARY" . equalsIgnoreCase ( columnTypeName ) || "LONG VARCHAR" . equalsIgnoreCase ( columnTypeName ) ) ) { columnSize = null ; } DataType type = new DataType ( columnTypeName ) ; type . setDataTypeId ( dataType ) ; /*
         * According to the description of DatabaseMetaData.getColumns, the content of the "COLUMN_SIZE" column is
         * pretty worthless for datetime/timestamp columns:
         *
         * "For datetime datatypes, this is the length in characters of the String representation
         * (assuming the maximum allowed precision of the fractional seconds component)."
         * In the case of TIMESTAMP columns, the information we are really looking for
         * (the fractional digits) is located in the column DECIMAL_DIGITS.
         */ int jdbcType = columnMetadataResultSet . getInt ( "DATA_TYPE" ) ; // Java 8 compatibility notes: When upgrading this project to JDK8 and beyond, also execute this if-branch // if jdbcType is TIMESTAMP_WITH_TIMEZONE (does not exist yet in JDK7) if ( jdbcType == Types . TIMESTAMP ) { if ( decimalDigits == null ) { type . setColumnSize ( null ) ; } else { type . setColumnSize ( ( decimalDigits != database . getDefaultFractionalDigitsForTimestamp ( ) ) ? decimalDigits : null ) ; } type . setDecimalDigits ( null ) ; } else { type . setColumnSize ( columnSize ) ; type . setDecimalDigits ( decimalDigits ) ; } type . setRadix ( radix ) ; type . setCharacterOctetLength ( characterOctetLength ) ; type . setColumnSizeUnit ( columnSizeUnit ) ; return type ; }
Processes metadata of a column, e.g. name, type and default value. We start with the result of the JDBC
{@link DatabaseMetaData}.getColumns() method. Depending on Database, additional columns might be present.

@param columnMetadataResultSet the result from the JDBC getColumns() call for the column
@param column                  logical definition of the column (object form)
@param database                the database from which the column originates
@return a DataType object with detailed information about the type
@throws DatabaseException If an error occurs during processing (mostly caused by Exceptions in JDBC calls)
Processes metadata of a column e . g . name type and default value . We start with the result of the JDBC { @link DatabaseMetaData } . getColumns () method . Depending on Database additional columns might be present .