Java SQL Type sqlType4Object(Object obj)

Here you can find the source of sqlType4Object(Object obj)

Description

sql Type Object

License

Open Source License

Declaration

public static int sqlType4Object(Object obj) throws SQLException 

Method Source Code

//package com.java2s;
/* Datamodel license.//from w  ww.  j av  a2  s  . c o  m
 * Exclusive rights on this code in any form
 * are belong to it's author. This code was
 * developed for commercial purposes only. 
 * For any questions and any actions with this
 * code in any form you have to contact to it's
 * author.
 * All rights reserved.
 */

import java.sql.*;

public class Main {
    public static int sqlType4Object(Object obj) throws SQLException {
        if (obj instanceof String) {
            return Types.VARCHAR;
        } else if (obj instanceof java.math.BigDecimal) {
            return Types.NUMERIC;
        } else if (obj instanceof Boolean) {
            return Types.BOOLEAN;
        } else if (obj instanceof Integer) {
            return Types.INTEGER;
        } else if (obj instanceof Long) {
            return Types.BIGINT;
        } else if (obj instanceof Float) {
            return Types.REAL;
        } else if (obj instanceof Double) {
            return Types.DOUBLE;
        } else if (obj instanceof byte[]) {
            return Types.BINARY;
        } else if (obj instanceof java.sql.Date) {
            return Types.DATE;
        } else if (obj instanceof java.sql.Time) {
            return Types.TIME;
        } else if (obj instanceof java.sql.Timestamp) {
            return Types.TIMESTAMP;
        } else if (obj instanceof java.sql.Clob) {
            return Types.CLOB;
        } else if (obj instanceof Blob) {
            return Types.BLOB;
        } else if (obj instanceof java.sql.Array) {
            return Types.ARRAY;
        } else if (obj instanceof java.sql.Struct) {
            return Types.STRUCT;
        } else if (obj instanceof java.sql.Ref) {
            return Types.REF;
        } else {
            return Types.JAVA_OBJECT;
        }
    }
}

Related

  1. readObject(DataInput in, int sqlType)
  2. resolveEscapes(String escaped, boolean noBackslashEscapes)
  3. setFieldValue(Object oBean, String sFieldName, Object oValue)
  4. setProperty(Object object, String name, String value)
  5. sqlType2Name(int sqlType)
  6. sqlTypeFromString(String sqlType)
  7. sqlTypeIsNumeric(int sqlType)
  8. sqlTypeName(final int value)
  9. sqlTypeString(int sqlType)