Java SQL Type getSqlType(String cubridType)

Here you can find the source of getSqlType(String cubridType)

Description

get the java.sql type map to cubrid data type.

License

Open Source License

Parameter

Parameter Description
cubridType a parameter

Declaration

public static int getSqlType(String cubridType) 

Method Source Code

//package com.java2s;
import java.sql.Types;

public class Main {
    /**/*from   ww w .j a v a2  s.  c o  m*/
     * get the java.sql type map to cubrid data type.
     * 
     * @param cubridType
     * @return
     */
    public static int getSqlType(String cubridType) {
        if (cubridType == null || cubridType.trim().equals("")) {
            return Types.VARCHAR;
        }

        cubridType = cubridType.toUpperCase();
        if (cubridType.equals("CHAR")) {
            return Types.CHAR;
        } else if (cubridType.equals("VARCHAR")) {
            return Types.VARCHAR;
        } else if (cubridType.equals("STRING")) {
            return Types.VARCHAR;
        } else if (cubridType.equals("NCHAR")) {
            return Types.CHAR;
        } else if (cubridType.equals("BIT")) {
            return Types.BIT;
        } else if (cubridType.equals("BIT VARYING")) {
            return Types.BIT;
        } else if (cubridType.equals("NUMERIC")
                || cubridType.equals("DECIMAL")) {
            return Types.NUMERIC;
        } else if (cubridType.equals("INTEGER") || cubridType.equals("INT")) {
            return Types.INTEGER;
        } else if (cubridType.equals("SMALLINT")) {
            return Types.SMALLINT;
        } else if (cubridType.equals("MONETARY")) {
            return Types.VARCHAR;
        } else if (cubridType.equals("FLOAT") || cubridType.equals("REAL")) {
            return Types.FLOAT;
        } else if (cubridType.equals("DOUBLE PRECISION")
                || cubridType.equals("DOUBLE")) {
            return Types.DOUBLE;
        } else if (cubridType.equals("DATE")) {
            return Types.DATE;
        } else if (cubridType.equals("TIME")) {
            return Types.TIME;
        } else if (cubridType.equals("TIMESTAMP")) {
            return Types.TIMESTAMP;
        } else if (cubridType.equals("NULL")) {
            return Types.NULL;
        } else {
            return Types.OTHER;
        }
    }
}

Related

  1. getSQLAttributeType(int sqlType)
  2. getSQLException(String message, String sqlState, Exception exception)
  3. getSQLParameterSubstring(String value, int type)
  4. getSqlType(int type)
  5. getSqlType(Object param)
  6. getSQLType(String text)
  7. getSQLType(String type)
  8. getSqlTypeAsString(int jdbcType)
  9. getSQLTypeByName(String type)