Here you can find the source of getSqlType(Object param)
public static int getSqlType(Object param)
//package com.java2s; /**//from w ww.j a va 2 s .c o m * Copyright 2016 the Rex-Soft Group. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.math.BigDecimal; import java.sql.Blob; import java.sql.Clob; import java.sql.Types; import java.util.Date; public class Main { /** * Returns SQL type matches the object. * * 1. String - Types.VARCHAR * 2. int|Integer - Types.INTEGER * 3. BigDecimal - Types.NUMERIC * 4. long|Long - Types.BIGINT * 5. float|Float - Types.FLOAT * 6. double|Double - Types.DOUBLE * 7. Date - Types.DATE * 8. Time - Types.TIME * 9. etc */ public static int getSqlType(Object param) { int type; if (param == null) { type = Types.NULL; } else { if (param instanceof String) type = Types.VARCHAR; else if (param instanceof Integer) type = Types.INTEGER; else if (param instanceof Long) type = Types.BIGINT; else if (param instanceof Float) type = Types.FLOAT; else if (param instanceof Double) type = Types.DOUBLE; else if (param instanceof Short) type = Types.SMALLINT; else if (param instanceof BigDecimal) type = Types.NUMERIC; else if (param instanceof Date) type = Types.TIMESTAMP; else if (param.getClass().isArray() && param.getClass().getComponentType() == Byte.class) type = Types.VARBINARY; else if (param instanceof Blob) type = Types.BLOB; else if (param instanceof Clob) type = Types.CLOB; else type = Types.OTHER; } return type; } }