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

StringgetJavaTypeFromSqlType(int sqlType)
get Java Type From Sql Type
String jtype;
switch (sqlType) {
case Types.BIT:
    jtype = "Boolean";
    break;
case Types.ARRAY:
    jtype = "Array";
    break;
...
ClassgetJavaTypeNameByJdbcType(int jdbcType)
get Java Type Name By Jdbc Type
switch (jdbcType) {
case Types.BIT: {
    return Boolean.class;
case Types.TINYINT: {
    return Byte.class;
case Types.SMALLINT: {
...
intgetJdbcType(int firebirdType)
get Jdbc Type
switch (firebirdType) {
case smallint_type:
    return Types.SMALLINT;
case integer_type:
    return Types.INTEGER;
case quad_type:
    return Types.ARRAY;
case float_type:
...
intgetJdbcType(String datatype)
get Jdbc Type
int jdbcType = 0;
if ("BLOB".equals(datatype)) {
    jdbcType = Types.BLOB;
} else if ("CHAR".equals(datatype)) {
    jdbcType = Types.CHAR;
} else if ("CLOB".equals(datatype)) {
    jdbcType = Types.CLOB;
} else if ("DATE".equals(datatype)) {
...
intgetJdbcType(String typeName)
get Jdbc Type
Integer answer = nameToType.get(typeName);
if (answer == null) {
    answer = Types.OTHER;
return answer;
ClassgetJdbcTypeClass(int type)
get Jdbc Type Class
Class<?> result = Object.class;
switch (type) {
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
case Types.CLOB:
    result = String.class;
    break;
...
intgetJDBCTypeForNamedType(String aTypeName)
Gets the JDBC datatype identifier corresponding to the given named datatype.
int jdbcTypeID = 0;
if (aTypeName.equalsIgnoreCase(TYPENAME_INTEGER) || aTypeName.equalsIgnoreCase(TYPENAME_INT)) {
    jdbcTypeID = java.sql.Types.INTEGER; 
} else if (aTypeName.equalsIgnoreCase(TYPENAME_DECIMAL) || aTypeName.equalsIgnoreCase(TYPENAME_DEC)
        || aTypeName.equalsIgnoreCase(TYPENAME_NUMERIC) || aTypeName.equalsIgnoreCase("NUM")) { 
    jdbcTypeID = java.sql.Types.DECIMAL; 
} else if (aTypeName.equalsIgnoreCase(TYPENAME_VARCHAR)
        || aTypeName.equalsIgnoreCase(TYPENAME_CHARACTER_VARYING)
...
StringgetJdbcTypeName(int jdbcType)
get Jdbc Type Name
if (map != null)
    return (String) map.get(new Integer(jdbcType));
map = new HashMap();
Field[] fields = java.sql.Types.class.getFields();
for (int i = 0; i < fields.length; i++) {
    try {
        String name = fields[i].getName();
        Integer value = (Integer) fields[i].get(null);
...
StringgetJDBCTypeName(int value)
get JDBC Type Name
if (jdbcTypeValues == null) {
    jdbcTypeValues = new HashMap<Object, String>();
    Field[] fields = Types.class.getFields();
    for (int i = 0; i < fields.length; i++) {
        Field field = fields[i];
        if (Modifier.isStatic(field.getModifiers())) {
            try {
                jdbcTypeValues.put(field.get(Types.class), field.getName());
...
MapgetJdbcTypeNames()
get Jdbc Type Names
if (jdbcTypeNames == null) {
    Map<Integer, String> aux = new HashMap<>();
    for (Field field : Types.class.getFields()) {
        try {
            aux.put((Integer) field.get(null), field.getName());
        } catch (IllegalArgumentException iae) {
        } catch (IllegalAccessException iae) {
    jdbcTypeNames = aux;
return jdbcTypeNames;