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

intgetNumTypeWidth(int type)
get Num Type Width
switch (type) {
case Types.TINYINT:
    return 1;
case Types.SMALLINT:
    return 2;
case Types.INTEGER:
    return 4;
case Types.BIGINT:
...
ObjectgetObject(int sqlType, String value)
get the value through different object .
if (value == null || value.equalsIgnoreCase("null")) {
    return null;
if (sqlType == Types.CHAR) {
    return value;
} else if (sqlType == Types.VARCHAR) {
    return value;
} else if (sqlType == Types.BIT) {
...
intgetObjectType(Object param)
get Object Type
int value = 0;
if (param == null) {
    value = Types.NULL;
} else if (param instanceof Integer) {
    value = Types.INTEGER;
} else if (param instanceof String) {
    value = Types.VARCHAR;
} else if (param instanceof Double) {
...
intgetObjectType(Object param)
get Object Type
if (param instanceof Integer) {
    return Types.INTEGER;
} else if (param instanceof String) {
    return Types.VARCHAR;
} else if (param instanceof Double) {
    return Types.DOUBLE;
} else if (param instanceof Float) {
    return Types.FLOAT;
...
StringgetOdaTypeName(int odaTypeCode)
Returns oda type name
switch (odaTypeCode) {
case Types.INTEGER:
    return "INT"; 
case Types.DOUBLE:
case Types.FLOAT:
    return "DOUBLE"; 
case Types.VARCHAR:
    return "STRING"; 
...
Class[]getParamArray(String signature, int numParam, boolean returnAllParams)
Builds an array of Class type for the given signature.
ArrayList param = new ArrayList();
boolean outMode = false;
for (int index = 0; index < signature.length(); index++) {
    switch (signature.charAt(index)) {
    case ')':
        break;
    case '[':
        outMode = true; 
...
StringgetPartitionSizeValidationError(int colType, String column, String partitionSize)
get Partition Size Validation Error
switch (colType) {
case Types.TINYINT:
case Types.SMALLINT:
case Types.INTEGER:
    try {
        int intVal = Integer.parseInt(partitionSize);
        if (intVal <= 0) {
            return createPartitionSizeValidationError(column, partitionSize, colType,
...
StringgetPreferredHibernateType(int sqlType, int size, int precision, int scale, boolean nullable, boolean generatedIdentifier)
get Preferred Hibernate Type
boolean returnNullable = nullable || generatedIdentifier;
if ((sqlType == Types.DECIMAL || sqlType == Types.NUMERIC) && scale <= 0) { 
    if (precision == 1) {
        return returnNullable ? Boolean.class.getName() : "boolean"; 
    } else if (precision < 3) {
        return returnNullable ? Byte.class.getName() : "byte"; 
    } else if (precision < 5) {
        return returnNullable ? Short.class.getName() : "short"; 
...
Map,Method>getPreparedStatementSetMethodMap()
Gets prepared statement set method map.
Map<Class<?>, Method> map = new HashMap<Class<?>, Method>();
try {
    map.put(Long.class, PreparedStatement.class.getMethod("setLong", int.class, long.class));
    map.put(int.class, PreparedStatement.class.getMethod("setLong", int.class, long.class));
    map.put(String.class, PreparedStatement.class.getMethod("setString", int.class, String.class));
    map.put(Object.class, PreparedStatement.class.getMethod("setObject", int.class, Object.class));
    map.put(Array.class, PreparedStatement.class.getMethod("setArray", int.class, Array.class));
    map.put(BigDecimal.class,
...
ObjectgetPrimitiveInstance(Type type, String valueString)
get Primitive Instance
Object typeInstanceObject = null;
try {
    if (valueString == null) {
        return null;
    } else if (type == int.class || type == Integer.class) {
        typeInstanceObject = Integer.parseInt(valueString);
    } else if (type == float.class || type == Float.class) {
        typeInstanceObject = Float.parseFloat(valueString);
...