Java SQL Type getObject(int sqlType, String value)

Here you can find the source of getObject(int sqlType, String value)

Description

get the value through different object .

License

Open Source License

Parameter

Parameter Description
sqlType a parameter
value a parameter

Declaration

public static Object getObject(int sqlType, String value) 

Method Source Code

//package com.java2s;
import java.sql.Types;

public class Main {
    /**//from w  ww .  j  ava  2 s. com
     * get the value through different object .
     * 
     * @param sqlType
     * @param value
     * @return
     */
    public static Object getObject(int sqlType, String value) {
        if (value == null || value.equalsIgnoreCase("null")) {
            return null;
        }

        if (sqlType == Types.CHAR) {
            return value;
        } else if (sqlType == Types.VARCHAR) {
            return value;
        } else if (sqlType == Types.BIT) {
            return value;
        } else if (sqlType == Types.INTEGER) {
            return new Integer(value);
        } else if (sqlType == Types.NUMERIC) {
            return new Double(value);
        } else if (sqlType == Types.FLOAT) {
            return new Float(value);
        } else if (sqlType == Types.DOUBLE) {
            return new Double(value);
        } else if (sqlType == Types.SMALLINT) {
            return new Short(value);
        } else if (sqlType == Types.DATE) {
            return value;
        } else if (sqlType == Types.TIME) {
            return value;
        } else if (sqlType == Types.TIMESTAMP) {
            return value;
        } else if (sqlType == Types.ARRAY) {
            return value;
        } else if (sqlType == Types.NULL) {
            return null;
        } else {
            return value;
        }
    }
}

Related

  1. getNameByType(int sqlType)
  2. getNameFromJdbcType(int jdbcType)
  3. getNextQuotes(String lastQuotes, int lastType)
  4. getNumberType(Integer precision, Integer scale)
  5. getNumTypeWidth(int type)
  6. getObjectType(Object param)
  7. getObjectType(Object param)
  8. getOdaTypeName(int odaTypeCode)
  9. getParamArray(String signature, int numParam, boolean returnAllParams)