Java SQL Type toSqlType(String clickshouseType)

Here you can find the source of toSqlType(String clickshouseType)

Description

to Sql Type

License

Apache License

Declaration

public static int toSqlType(String clickshouseType) 

Method Source Code

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

import java.sql.Types;

public class Main {
    public static int toSqlType(String clickshouseType) {
        if (clickshouseType.startsWith("Int")
                || clickshouseType.startsWith("UInt")) {
            return clickshouseType.endsWith("64") ? Types.BIGINT
                    : Types.INTEGER;
        }/*from www. ja  va 2s .  co  m*/
        if ("String".equals(clickshouseType))
            return Types.VARCHAR;
        if (clickshouseType.startsWith("Float"))
            return Types.FLOAT;
        if ("Date".equals(clickshouseType))
            return Types.DATE;
        if ("DateTime".equals(clickshouseType))
            return Types.TIMESTAMP;
        if ("FixedString".equals(clickshouseType))
            return Types.BLOB;
        if (isArray(clickshouseType))
            return Types.ARRAY;

        // don't know what to return actually
        return Types.VARCHAR;
    }

    private static boolean isArray(String clickhouseType) {
        return clickhouseType.startsWith("Array(")
                && clickhouseType.endsWith(")");
    }
}

Related

  1. toClass(int sqlType, boolean isUnsigned)
  2. toHCatType(int sqlType)
  3. toJavaType(int sqlType, String type)
  4. toOdaDataType(Class odiTypeClass)
  5. toSqlType(Class clazz)
  6. toSqlType(String clickshouseType)
  7. translateType(int sqlType)
  8. typeName(int type)
  9. typeNameToValueType(String typeName)