Java SQL Type getTypeName(int dataType)

Here you can find the source of getTypeName(int dataType)

Description

Given an int datatype, return the java.sql.Types name for that datatype.

License

Apache License

Parameter

Parameter Description
dataType The int datatype for which we need the string datatype name.

Return

A string representation of the datatype name.

Declaration

public static String getTypeName(int dataType) 

Method Source Code

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

import java.sql.Types;

public class Main {
    /**//from  w  w w  .  j  a  va2 s.  c o m
     * 
     * Given an int datatype, return the java.sql.Types name for that datatype.
     * 
     * @param dataType
     *          The int datatype for which we need the string datatype name.
     * 
     * @return A string representation of the datatype name.
     * 
     */
    public static String getTypeName(int dataType) {
        switch (dataType) {
        case Types.BIGINT:
            return "BIGINT";
        case Types.BINARY:
            return "BINARY";
        case Types.BIT:
            return "BIT";
        case Types.CHAR:
            return "CHAR";
        case Types.DATE:
            return "DATE";
        case Types.DECIMAL:
            return "DECIMAL";
        case Types.DOUBLE:
            return "DOUBLE";
        case Types.FLOAT:
            return "FLOAT";
        case Types.INTEGER:
            return "INTEGER";
        case Types.LONGVARBINARY:
            return "LONGVARBINARY";
        case Types.LONGVARCHAR:
            return "LONGVARCHAR";
        case Types.NULL:
            return "NULL";
        case Types.NUMERIC:
            return "NUMERIC";
        case Types.OTHER:
            return "OTHER";
        case Types.REAL:
            return "REAL";
        case Types.SMALLINT:
            return "SMALLINT";
        case Types.TIME:
            return "TIME";
        case Types.TIMESTAMP:
            return "TIMESTAMP";
        case Types.TINYINT:
            return "TINYINT";
        case Types.VARBINARY:
            return "VARBINARY";
        case Types.VARCHAR:
            return "VARCHAR";
        }

        return "UNKNOWN";
    }
}

Related

  1. getStringFormat(int colType)
  2. getTableTypes(DatabaseMetaData dbmd)
  3. getTinyIntTypeString(Connection conn)
  4. getType(int csqltype)
  5. getTypeforValue(int type)
  6. getTypeName(int typeNumber)
  7. getTypeNameForJDBCType(int jdbcType)
  8. getTypeStringForObject(Object o)
  9. getUDTOwner(String typeName, String dbName, Connection conn)