Java SQL Type typeName(int type)

Here you can find the source of typeName(int type)

Description

Returns the name associated with a SQL type.

License

Open Source License

Parameter

Parameter Description
type the SQL type

Return

the name of the type

Declaration

public static String typeName(int type) 

Method Source Code

//package com.java2s;
/*/*w w  w.  java 2s . c o  m*/
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

import java.sql.Types;

public class Main {
    /**
     * Returns the name associated with a SQL type.
     *
     * @param type the SQL type
     * @return the name of the type
     */
    public static String typeName(int type) {

        switch (type) {
        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";
        default:
            return "Unknown";
        }
    }
}

Related

  1. toOdaDataType(Class odiTypeClass)
  2. toSqlType(Class clazz)
  3. toSqlType(String clickshouseType)
  4. toSqlType(String clickshouseType)
  5. translateType(int sqlType)
  6. typeNameToValueType(String typeName)
  7. typeToClass(int type)
  8. typeToString(int sqlType)
  9. writeObject(Object obj, int sqlType, DataOutput out)