Java SQL Type getColumnClass(int sqlType)

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

Description

This method return the Class of a specific SQL Type, defined in java.sql.Types.

License

Open Source License

Parameter

Parameter Description
sqlType SQL Type.

Return

The Class relative to the SQL Type.

Declaration

public static Class getColumnClass(int sqlType) 

Method Source Code

//package com.java2s;

import java.sql.Types;

public class Main {
    /**//from www  .  ja v a 2 s  . c o  m
     * This method return the Class of a specific SQL Type, defined in
     * java.sql.Types.
     * 
     * @param sqlType
     *            SQL Type.
     * @return The Class relative to the SQL Type.
     */
    public static Class getColumnClass(int sqlType) {
        switch (sqlType) {
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGVARCHAR:
            return String.class;

        case Types.BIT:
        case Types.BOOLEAN:
            return boolean.class;

        case Types.TINYINT:
        case Types.SMALLINT:
        case Types.INTEGER:
            return Integer.class;

        case Types.BIGINT:
            return Long.class;

        case Types.FLOAT:
        case Types.DOUBLE:
        case Types.DECIMAL:
        case Types.NUMERIC:
        case Types.REAL:
            return Double.class;

        case Types.DATE:
            return java.util.Date.class;

        case Types.TIMESTAMP:
        case Types.TIME:
            return java.sql.Timestamp.class;

        default:
            return Object.class;

        /*
         * types not recognized yet case Types.ARRAY : case Types.BINARY : case
         * Types.BLOB : case Types.CLOB : case Types.DATALINK : case
         * Types.DISTINCT : case Types.JAVA_OBJECT : case Types.LONGVARBINARY :
         * case Types.NULL : case Types.OTHER : case Types.REF : case
         * Types.STRUCT : case Types.VARBINARY :
         */
        }
    }
}

Related

  1. getCharStream(Object value, int columnType)
  2. getClass(int sqlType, int precision, int scale)
  3. getClassByJdbcType(int type, int decimalDigits)
  4. getCloverTypeFromJdbcType(int jdbcDataType)
  5. getColumeTypeDesc(Class clazz)
  6. getColumnType(Connection conn, String table, String column)
  7. getColumnType(String type)
  8. getConnection(String jdbcUrl, Properties properties)
  9. getDbDataType(Object o)