Java SQL Type translateType(int sqlType)

Here you can find the source of translateType(int sqlType)

Description

Translate a SQL type into one of a few values.

License

Apache License

Parameter

Parameter Description
sqlType the type to be translated into a simpler type

Return

the new SQL type

Declaration

public static int translateType(int sqlType) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Types;

public class Main {
    /**/*from www.  j  a v a2  s  .  co m*/
     * Translate a SQL type into one of a few values.
     * All integer types are translated to Integer.
     * All real types are translated to Double.
     * All string types are translated to String.
     * All other types are left untouched.
     * @param sqlType the type to be translated into a simpler type
     * @return the new SQL type
     */
    public static int translateType(int sqlType) {

        int retType = sqlType;
        if (Types.BIT == sqlType || Types.TINYINT == sqlType || Types.SMALLINT == sqlType
                || Types.INTEGER == sqlType)
            retType = Types.INTEGER;
        else if (Types.CHAR == sqlType || Types.VARCHAR == sqlType)
            retType = Types.VARCHAR;
        else if (Types.DECIMAL == sqlType || Types.DOUBLE == sqlType || Types.FLOAT == sqlType
                || Types.NUMERIC == sqlType || Types.REAL == sqlType)
            retType = Types.NUMERIC;

        return retType;
    }
}

Related

  1. toJavaType(int sqlType, String type)
  2. toOdaDataType(Class odiTypeClass)
  3. toSqlType(Class clazz)
  4. toSqlType(String clickshouseType)
  5. toSqlType(String clickshouseType)
  6. typeName(int type)
  7. typeNameToValueType(String typeName)
  8. typeToClass(int type)
  9. typeToString(int sqlType)