Java Utililty Methods SQL Type

List of utility methods to do SQL Type

Description

The list of methods to do SQL Type are organized into topic(s).

Method

voidsetProperty(Object object, String name, String value)
Tries to set the property 'name' to `value` in the given object.
Class<?> type = object.getClass();
PropertyDescriptor[] descriptors;
try {
    descriptors = Introspector.getBeanInfo(type).getPropertyDescriptors();
} catch (Exception ex) {
    throw new SQLException(ex);
List<String> names = new ArrayList<>();
...
StringsqlType2Name(int sqlType)
sql Type Name
try {
    Class cls = java.sql.Types.class; 
    java.lang.reflect.Field[] fields = cls.getFields();
    for (int i = 0; i < fields.length; i++) {
        if (fields[i].getInt(null) == sqlType)
            return fields[i].getName();
} catch (Throwable ex) {
...
intsqlType4Object(Object obj)
sql Type Object
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;
...
intsqlTypeFromString(String sqlType)
sql Type From String
sqlType = sqlType.toUpperCase();
switch (sqlType) {
case "ARRAY":
    return (Types.ARRAY);
case "BIGINT":
    return (Types.BIGINT);
case "BINARY":
    return (Types.BINARY);
...
booleansqlTypeIsNumeric(int sqlType)
sql Type Is Numeric
switch (sqlType) {
case Types.TINYINT:
case Types.SMALLINT:
case Types.BIGINT:
case Types.DECIMAL:
case Types.INTEGER:
case Types.FLOAT:
case Types.DOUBLE:
...
StringsqlTypeName(final int value)
sql Type Name
for (final Field field : Types.class.getFields()) {
    final int modifiers = field.getModifiers();
    if (!Modifier.isPublic(modifiers)) {
        continue;
    if (!Modifier.isStatic(modifiers)) {
        continue;
    if (!Integer.TYPE.equals(field.getType())) {
        continue;
    if (field.getInt(null) == value) {
        return field.getName();
return null;
StringsqlTypeString(int sqlType)
sql Type String
switch (sqlType) {
case Types.BIT:
    return "BIT";
case Types.TINYINT:
    return "TINYINT";
case Types.SMALLINT:
    return "SMALLINT";
case Types.INTEGER:
...
ClasssqlTypeToClass(int sqlType, String className)
Mapping as defined by JDBC 3 Spec , page B-177, table B-1 JBDC Types mapped to Java Types.
if ((sqlType == Types.BOOLEAN) || (sqlType == Types.BIT)) {
    return Boolean.class;
if ((sqlType == Types.CHAR) || (sqlType == Types.VARCHAR) || (sqlType == Types.LONGVARCHAR)) {
    return String.class;
if ((sqlType == Types.CHAR) || (sqlType == Types.VARCHAR)) {
    return String.class;
...
ClasssqlTypeToClassType(final Integer sqlType)
sql Type To Class Type
if (sqlType.equals(Types.ARRAY)) {
    return Array.class;
} else if (sqlType.equals(Types.BIGINT)) {
    return BigInteger.class;
} else if (sqlType.equals(Types.BINARY)) {
    return Object.class;
} else if (sqlType.equals(Types.BIT)) {
    return Byte.class;
...
StringsqlTypeToHiveType(Integer type)
sql Type To Hive Type
switch (type) {
case Types.BIGINT:
    return "bigint";
case Types.NUMERIC:
case Types.DOUBLE:
case Types.DECIMAL:
    return "double";
case Types.INTEGER:
...