Java SQL Type getObjectType(Object param)

Here you can find the source of getObjectType(Object param)

Description

get Object Type

License

Apache License

Declaration

public static int getObjectType(Object param) 

Method Source Code


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

import java.math.BigDecimal;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;

import java.sql.Date;

import java.sql.Timestamp;
import java.sql.Types;

public class Main {
    public static int getObjectType(Object param) {
        int value = 0;
        if (param == null) {
            value = Types.NULL;/*from   w w  w .j  av a  2 s  .  c  o m*/
        } else if (param instanceof Integer) {
            value = Types.INTEGER;
        } else if (param instanceof String) {
            value = Types.VARCHAR;
        } else if (param instanceof Double) {
            value = Types.DOUBLE;
        } else if (param instanceof Float) {
            value = Types.FLOAT;
        } else if (param instanceof Long) {
            value = Types.BIGINT;
        } else if (param instanceof Boolean) {
            value = Types.BOOLEAN;
        } else if (param instanceof Date) {
            value = Types.DATE;
        } else if (param instanceof Blob) {
            value = Types.BLOB;
        } else if (param instanceof byte[]) {
            value = Types.BLOB;
        } else if (param instanceof Clob) {
            value = Types.CLOB;
        } else if (param instanceof Timestamp) {
            value = Types.TIMESTAMP;
        } else if (param instanceof BigDecimal) {
            value = Types.DECIMAL;
        } else if (param instanceof Array) {
            value = Types.ARRAY;
        }
        return value;
    }
}

Related

  1. getNextQuotes(String lastQuotes, int lastType)
  2. getNumberType(Integer precision, Integer scale)
  3. getNumTypeWidth(int type)
  4. getObject(int sqlType, String value)
  5. getObjectType(Object param)
  6. getOdaTypeName(int odaTypeCode)
  7. getParamArray(String signature, int numParam, boolean returnAllParams)
  8. getPartitionSizeValidationError(int colType, String column, String partitionSize)
  9. getPreferredHibernateType(int sqlType, int size, int precision, int scale, boolean nullable, boolean generatedIdentifier)