Here you can find the source of toClass(final int type)
Parameter | Description |
---|---|
type | The java.sql.Types value to convert to its corresponding class |
public static Class<?> toClass(final int type)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; import java.sql.Types; public class Main { /**// w w w. j a v a 2 s . c o m * Translates a data type from an integer (java.sql.Types value) to a class type. * * @param type * The java.sql.Types value to convert to its corresponding class * @return The class that corresponds to the given java.sql.Types value, or Object.class if the type has no known mapping. */ public static Class<?> toClass(final int type) { Class<?> result = null; switch (type) { case Types.CHAR: result = Character.class; break; case Types.VARCHAR: case Types.LONGVARCHAR: result = String.class; break; case Types.NUMERIC: case Types.DECIMAL: result = BigDecimal.class; break; case Types.BIT: result = Boolean.class; break; case Types.TINYINT: result = Byte.class; break; case Types.SMALLINT: result = Short.class; break; case Types.INTEGER: result = Integer.class; break; case Types.BIGINT: result = Long.class; break; case Types.REAL: case Types.FLOAT: result = Float.class; break; case Types.DOUBLE: result = Double.class; break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: result = Byte[].class; break; case Types.DATE: result = java.sql.Date.class; break; case Types.TIME: result = java.sql.Time.class; break; case Types.TIMESTAMP: result = java.sql.Timestamp.class; break; default: result = Object.class; break; } return result; } }