Java SQL Type isJDBCType(final int type)

Here you can find the source of isJDBCType(final int type)

Description

This function returns true if the value type maps to a valid JDBC Type.

License

Open Source License

Parameter

Parameter Description
type The value to check

Return

true if type is one of the constants in java.sql.Types

Declaration

public static boolean isJDBCType(final int type) 

Method Source Code


//package com.java2s;
/*//from www. ja  v  a  2 s  . c  o  m
 * Copyright (C) 2001-2004 Red Hat, Inc. All Rights Reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

import java.sql.Types;

public class Main {
    /**
     *  This function returns true if the value <code>type</code>
     *  maps to a valid JDBC Type. Mainly intended for use in
     *  precondition statements.
     *
     *  @param type The value to check
     *  @return true if type is one of the constants in <code>java.sql.Types</code>
     *
     */
    public static boolean isJDBCType(final int type) {
        // Kinda ugly to have one big case, but it's actually the
        // fastest lookup.
        switch (type) {
        case Types.ARRAY:
        case Types.BIGINT:
        case Types.BINARY:
        case Types.BIT:
        case Types.BLOB:
        case Types.CHAR:
        case Types.CLOB:
        case Types.DATE:
        case Types.DECIMAL:
        case Types.DISTINCT:
        case Types.DOUBLE:
        case Types.FLOAT:
        case Types.INTEGER:
        case Types.JAVA_OBJECT:
        case Types.LONGVARBINARY:
        case Types.LONGVARCHAR:
        case Types.NULL:
        case Types.NUMERIC:
        case Types.OTHER:
        case Types.REAL:
        case Types.REF:
        case Types.SMALLINT:
        case Types.STRUCT:
        case Types.TIME:
        case Types.TIMESTAMP:
        case Types.TINYINT:
        case Types.VARBINARY:
        case Types.VARCHAR:
            return true;
        default:
            return false;
        }

    }
}

Related

  1. isBoolean(int dataType)
  2. isCharacterTypeWithLength(int aSqlType)
  3. isClobType(int sqlType)
  4. isDataNeedsQuotes(int type)
  5. isDigitalType(int sqlType)
  6. isLobColumn(int dataType)
  7. isNativeType(final Class type)
  8. isNumberic(int type)
  9. isNumberType(int aSqlType)