Java SQL Type sqlTypeToSqlTypeName(final int type)

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

Description

sql Type To Sql Type Name

License

Open Source License

Declaration

public static String sqlTypeToSqlTypeName(final int type) 

Method Source Code

//package com.java2s;
/**//from w w  w .  j a  v a 2s. com
 * JDBCPersistence framework for java
 *   Copyright (C) 2004-2014 Alex Rojkov
 *
 *    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
 *
 *    You can contact me by email jdbcpersistence   a t   gmail    d o t    com
 * */

import java.lang.reflect.Field;
import java.sql.*;

public class Main {
    public static String sqlTypeToSqlTypeName(final int type) {
        try {
            final Integer typeValue = new Integer(type);
            final Field[] fields = Types.class.getDeclaredFields();
            for (int i = 0; i < fields.length; i++) {
                final Field field = fields[i];
                final Integer l = (Integer) field.get(null);
                if (typeValue.equals(l)) {
                    return field.getName();
                }
            }
        } catch (IllegalAccessException e) {
        }

        return "" + type;
    }
}

Related

  1. sqlTypeString(int sqlType)
  2. sqlTypeToClass(int sqlType, String className)
  3. sqlTypeToClassType(final Integer sqlType)
  4. sqlTypeToHiveType(Integer type)
  5. sqlTypeToSetterGetter(int sqlType)
  6. toClass(final int type)
  7. toClass(int sqlType, boolean isUnsigned)
  8. toHCatType(int sqlType)
  9. toJavaType(int sqlType, String type)