Java SQL Type convertToJDBCType(String talendType)

Here you can find the source of convertToJDBCType(String talendType)

Description

convert To JDBC Type

License

Open Source License

Declaration

public static int convertToJDBCType(String talendType) 

Method Source Code

//package com.java2s;
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt

import java.sql.Types;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class Main {
    private static Map<String, Integer> dbMap;

    public static int convertToJDBCType(String talendType) {
        Integer type = getTalendDBMap().get(talendType.trim());
        return null == type ? 0 : type;
    }//from  w  w  w  . java2  s . co m

    public static Map<String, Integer> getTalendDBMap() {
        if (dbMap == null) {
            dbMap = new HashMap<String, Integer>();
            dbMap.put(talendDBTypeName(Boolean.class), Types.BOOLEAN);
            dbMap.put(talendDBTypeName(Byte.class), Types.DECIMAL);
            dbMap.put(talendDBTypeName(Character.class), Types.CHAR);
            dbMap.put(talendDBTypeName(Date.class), Types.DATE);
            dbMap.put(talendDBTypeName(String.class), Types.CLOB);
            dbMap.put(talendDBTypeName(Double.class), Types.DOUBLE);
            dbMap.put(talendDBTypeName(Float.class), Types.FLOAT);
            dbMap.put(talendDBTypeName(Integer.class), Types.INTEGER);
            dbMap.put(talendDBTypeName(Long.class), Types.INTEGER);
            dbMap.put(talendDBTypeName(Short.class), Types.SMALLINT);
            dbMap.put("DECIMAL", Types.DECIMAL);
            dbMap.put("VARCHAR", Types.VARCHAR);
            dbMap.put("TIMESTAMP", Types.TIMESTAMP);
            dbMap.put("BINARY", Types.BINARY);
            dbMap.put("REF", Types.REF);
            dbMap.put("DATALINK", Types.DATALINK);
            dbMap.put("BIGINT", Types.BIGINT);
            dbMap.put("CHAR", Types.CHAR);
        }
        return dbMap;
    }

    private static String talendDBTypeName(Class<?> nullableClass) {
        return nullableClass.getSimpleName().toUpperCase();
    }
}

Related

  1. convertOracleValue(Object value, int type)
  2. convertParam(Object oValue, Class cType, String sFieldName)
  3. convertSQLtype2JavaClassName(int type)
  4. convertStringToType(String type)
  5. convertTemporal(Object value, int srcType, int destType)
  6. convertToProperty(Object value)
  7. convertToStream(final Object o)
  8. convertToString(int datatype)
  9. convertType(final int type)