Java SQL Type getJdbcTypeClass(int type)

Here you can find the source of getJdbcTypeClass(int type)

Description

get Jdbc Type Class

License

Open Source License

Declaration

public static Class<?> getJdbcTypeClass(int type) 

Method Source Code

//package com.java2s;
/**/*ww w .j a va 2  s .  c o m*/
 * Copyright (c) 2015-present Jorge D?az All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

import java.sql.Types;

public class Main {
    public static Class<?> getJdbcTypeClass(int type) {
        Class<?> result = Object.class;

        switch (type) {
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGVARCHAR:
        case Types.CLOB:
            result = String.class;
            break;

        case Types.NUMERIC:
        case Types.DECIMAL:
            result = java.math.BigDecimal.class;
            break;

        case Types.BIT:
        case Types.BOOLEAN:
            result = Boolean.class;
            break;

        case Types.TINYINT:
            result = Byte.class;
            break;

        case Types.SMALLINT:
            result = Short.class;
            break;

        case Types.INTEGER:
            result = Integer.class;
            break;

        case Types.BIGINT:
            result = Long.class;
            break;

        case Types.REAL:
        case Types.FLOAT:
            result = Float.class;
            break;

        case Types.DOUBLE:
            result = Double.class;
            break;

        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
            result = Byte[].class;
            break;

        case Types.DATE:
            result = java.sql.Date.class;
            break;

        case Types.TIME:
            result = java.sql.Time.class;
            break;

        case Types.TIMESTAMP:
            result = java.sql.Timestamp.class;
            break;
        }

        return result;
    }
}

Related

  1. getJavaTypeFromSqlType(int sqlType)
  2. getJavaTypeNameByJdbcType(int jdbcType)
  3. getJdbcType(int firebirdType)
  4. getJdbcType(String datatype)
  5. getJdbcType(String typeName)
  6. getJDBCTypeForNamedType(String aTypeName)
  7. getJdbcTypeName(int jdbcType)
  8. getJDBCTypeName(int value)
  9. getJdbcTypeNames()