Java SQL Type getColumeTypeDesc(Class clazz)

Here you can find the source of getColumeTypeDesc(Class clazz)

Description

get Colume Type Desc

License

Open Source License

Declaration

public static String getColumeTypeDesc(Class<?> clazz) 

Method Source Code

//package com.java2s;
/*/*from w w w  .  j  av a2 s. c  o  m*/
 * Project: admin-parent
 * 
 * File Created at 2014-04-03
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */

import java.sql.Blob;

import java.util.Date;

public class Main {

    public static String getColumeTypeDesc(Class<?> clazz) {
        String result;
        if (clazz == boolean.class || clazz == Boolean.class) {
            result = "bit";
        } else if (clazz == short.class || clazz == Short.class) {
            result = "smallint(4)";
        } else if (clazz == int.class || clazz == Integer.class) {
            result = "int(11)";
        } else if (clazz == long.class || clazz == Long.class) {
            result = "bigint(20)";
        } else if (clazz == float.class || clazz == Float.class) {
            result = "float(10)";
        } else if (clazz == double.class || clazz == Double.class) {
            result = "double(20)";
        } else if (clazz == char.class || clazz == Character.class) {
            result = "char(1)";
        } else if (clazz == char[].class || clazz == byte[].class || clazz == String.class) {
            result = "varchar(100)";
        } else if (clazz == Date.class) {
            result = "datetime";
        } else if (clazz == Blob.class) {
            result = "blob";
        } else {
            result = null;
        }
        return result;
    }
}

Related

  1. getCastExpression(Class aClass)
  2. getCharStream(Object value, int columnType)
  3. getClass(int sqlType, int precision, int scale)
  4. getClassByJdbcType(int type, int decimalDigits)
  5. getCloverTypeFromJdbcType(int jdbcDataType)
  6. getColumnClass(int sqlType)
  7. getColumnType(Connection conn, String table, String column)
  8. getColumnType(String type)
  9. getConnection(String jdbcUrl, Properties properties)