Java SQL Type getNameByType(int sqlType)

Here you can find the source of getNameByType(int sqlType)

Description

Returns SQL type name by code.

License

Apache License

Parameter

Parameter Description
sqlType SQL type.

Return

SQL type name.

Declaration

public static String getNameByType(int sqlType) 

Method Source Code

//package com.java2s;
/**/*from   w  ww . j a  v a  2s . co  m*/
 * Copyright 2016 the Rex-Soft Group.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.sql.Types;

public class Main {
    /**
     * Returns SQL type name by code.
     * @param sqlType SQL type.
     * @return SQL type name.
     */
    public static String getNameByType(int sqlType) {
        switch (sqlType) {
        case Types.BIT:
            return "BIT";
        case Types.BIGINT:
            return "BIGINT";
        case Types.DECIMAL:
            return "DECIMAL";
        case Types.DOUBLE:
            return "DOUBLE";
        case Types.FLOAT:
            return "FLOAT";
        case Types.INTEGER:
            return "INTEGER";
        case Types.NUMERIC:
            return "NUMERIC";
        case Types.REAL:
            return "REAL";
        case Types.SMALLINT:
            return "SMALLINT";
        case Types.TINYINT:
            return "TINYINT";
        case Types.CHAR:
            return "CHAR";
        case Types.VARCHAR:
            return "VARCHAR";
        case Types.LONGVARCHAR:
            return "LONGVARCHAR";
        case Types.DATE:
            return "DATE";
        case Types.TIME:
            return "TIME";
        case Types.TIMESTAMP:
            return "TIMESTAMP";
        case Types.BINARY:
            return "BINARY";
        case Types.VARBINARY:
            return "VARBINARY";
        case Types.LONGVARBINARY:
            return "LONGVARBINARY";
        case Types.NULL:
            return "NULL";
        case Types.OTHER:
            return "OTHER";
        case Types.JAVA_OBJECT:
            return "JAVA_OBJECT";
        case Types.DISTINCT:
            return "DISTINCT";
        case Types.STRUCT:
            return "STRUCT";
        case Types.ARRAY:
            return "ARRAY";
        case Types.BLOB:
            return "BLOB";
        case Types.CLOB:
            return "CLOB";
        case Types.REF:
            return "REF";
        case Types.DATALINK:
            return "DATALINK";
        case Types.BOOLEAN:
            return "BOOLEAN";
        //         case Types.ROWID: return "ROWID";
        //         case Types.NCHAR: return "NCHAR";
        //         case Types.NVARCHAR: return "NVARCHAR";
        //         case Types.LONGNVARCHAR: return "LONGNVARCHAR";
        //         case Types.NCLOB: return "NCLOB";
        //         case Types.SQLXML: return "SQLXML";
        default:
            return "Unsupported";
        }
    }
}

Related

  1. getLength(String format, String columnTypeName)
  2. getLong(Object object)
  3. getMBTileData(int column, int row, int zoomLevel, String jdbcConnectionString)
  4. getMBTileData(int column, int row, int zoomLevel, String jdbcConnectionString)
  5. getMessages(Array arr)
  6. getNameFromJdbcType(int jdbcType)
  7. getNextQuotes(String lastQuotes, int lastType)
  8. getNumberType(Integer precision, Integer scale)
  9. getNumTypeWidth(int type)