Here you can find the source of getSqlTypeByValue(Object value)
Parameter | Description |
---|---|
value | a parameter |
public static int getSqlTypeByValue(Object value)
//package com.java2s; //License from project: Open Source License import java.sql.Types; public class Main { /**/*from w w w. j av a 2 s.c om*/ * Finds appropriate SQL type for the given value. * Returns Types.OTHER if not found. * * @param value * @return */ public static int getSqlTypeByValue(Object value) { if (value instanceof Integer) { return Types.INTEGER; } else if (value instanceof java.math.BigDecimal) { return Types.NUMERIC; } else if (value instanceof String) { return Types.VARCHAR; } else if (value instanceof Byte) { return Types.TINYINT; } else if (value instanceof Short) { return Types.SMALLINT; } else if (value instanceof Long) { return Types.BIGINT; } else if (value instanceof Float) { return Types.REAL; } else if (value instanceof Double) { return Types.DOUBLE; } else if (value instanceof byte[]) { return Types.VARBINARY; } else if (value instanceof java.sql.Date) { return Types.DATE; } else if (value instanceof java.sql.Time) { return Types.TIME; } else if (value instanceof java.sql.Timestamp) { return Types.TIMESTAMP; } else if (value instanceof Boolean) { return Types.BIT; } else if (value instanceof java.sql.Struct) { return Types.STRUCT; } else { return Types.OTHER; } } }