Java SQL Type getJavaTypeFromSqlType(int sqlType)

Here you can find the source of getJavaTypeFromSqlType(int sqlType)

Description

get Java Type From Sql Type

License

Apache License

Declaration

public static String getJavaTypeFromSqlType(int sqlType) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Types;

public class Main {
    public static String getJavaTypeFromSqlType(int sqlType) {
        String jtype;/*w w  w.java 2s. com*/
        switch (sqlType) {
        case Types.BIT:
            jtype = "Boolean";
            break;
        case Types.ARRAY:
            jtype = "Array";
            break;
        case Types.BINARY:
            jtype = "byte[]";
            break;
        case Types.BLOB:
            jtype = "Blob";
            break;
        case Types.CLOB:
            jtype = "Clob";
            break;
        case Types.LONGVARCHAR:
            jtype = "String";
            break;
        case Types.BOOLEAN:
            jtype = "Boolean";
            break;
        case Types.SMALLINT:
            jtype = "Short";
            break;
        case Types.REAL:
            jtype = "Float";
            break;
        case Types.VARCHAR:
            jtype = "String";
            break;
        case Types.BIGINT:
            jtype = "Long";
            break;
        case Types.CHAR:
            jtype = "String";
            break;
        case Types.DATE:
            jtype = "Date";
            break;
        case Types.TIMESTAMP:
            jtype = "Timestamp";
            break;
        case Types.DECIMAL:
            jtype = "BigDecimal";
            break;
        case Types.DOUBLE:
            jtype = "Double";
            break;
        case Types.FLOAT:
            jtype = "Double";
            break;
        case Types.INTEGER:
            jtype = "Integer";
            break;
        case Types.NCHAR:
            jtype = "String";
            break;
        case Types.NUMERIC:
            jtype = "BigDecimal";
            break;
        case Types.NVARCHAR:
            jtype = "String";
            break;
        case Types.TIME:
            jtype = "Time";
            break;
        case Types.TINYINT:
            jtype = "Integer";
            break;
        default:
            jtype = "String";
        }
        return jtype;
    }
}

Related

  1. getIntValue(String typeName)
  2. getJavaType(int dataType, int columnSize, int decimalDegit)
  3. getJavaType(int jdbcType)
  4. getJavaType(int sqlType)
  5. getJavaType(String rdbType)
  6. getJavaTypeNameByJdbcType(int jdbcType)
  7. getJdbcType(int firebirdType)
  8. getJdbcType(String datatype)
  9. getJdbcType(String typeName)