Java SQL Type getJavaTypeNameByJdbcType(int jdbcType)

Here you can find the source of getJavaTypeNameByJdbcType(int jdbcType)

Description

get Java Type Name By Jdbc Type

License

Open Source License

Parameter

Parameter Description
jdbcType a parameter

Return

Class

Declaration

public static Class getJavaTypeNameByJdbcType(int jdbcType) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.Types;

import java.util.Date;

public class Main {
    /**/*from  w  ww .  ja  v a2 s. co  m*/
     * @param jdbcType
     * @return Class
     */
    public static Class getJavaTypeNameByJdbcType(int jdbcType) {
        switch (jdbcType) {
        case Types.BIT: {
            return Boolean.class;
        }
        case Types.TINYINT: {
            return Byte.class;
        }
        case Types.SMALLINT: {
            return Short.class;
        }
        case Types.INTEGER: {
            return Integer.class;
        }
        case Types.BIGINT: {
            return Long.class;
        }
        case Types.DOUBLE:
        case Types.FLOAT: {
            return Double.class;
        }
        case Types.REAL: {
            return Float.class;
        }
        case Types.NUMERIC: {
            return Boolean.class;
        }
        case Types.DECIMAL: {
            return BigDecimal.class;
        }
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGVARCHAR: {
            return String.class;
        }
        case Types.DATE: {
            return Date.class;
        }
        case Types.TIME: {
            return Time.class;
        }
        case Types.TIMESTAMP: {
            return Timestamp.class;
        }
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
        case Types.CLOB:
        case Types.BLOB:
        case Types.STRUCT: {
            return Object.class;
        }
        default: {
            return Object.class;
        }
        }
    }
}

Related

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