Java SQL Type getJdbcTypeNames()

Here you can find the source of getJdbcTypeNames()

Description

get Jdbc Type Names

License

Open Source License

Declaration

public static Map<Integer, String> getJdbcTypeNames() 

Method Source Code

//package com.java2s;
/**/*from  w w  w . j a va  2s  .c o m*/
 * Copyright (c) 2015-present Jorge D?az 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.
 */

import java.lang.reflect.Field;

import java.sql.Types;

import java.util.HashMap;

import java.util.Map;

public class Main {
    private static Map<Integer, String> jdbcTypeNames = null;

    public static Map<Integer, String> getJdbcTypeNames() {
        if (jdbcTypeNames == null) {
            Map<Integer, String> aux = new HashMap<>();

            for (Field field : Types.class.getFields()) {
                try {
                    aux.put((Integer) field.get(null), field.getName());
                } catch (IllegalArgumentException iae) {
                } catch (IllegalAccessException iae) {
                }
            }

            jdbcTypeNames = aux;
        }

        return jdbcTypeNames;
    }
}

Related

  1. getJdbcType(String typeName)
  2. getJdbcTypeClass(int type)
  3. getJDBCTypeForNamedType(String aTypeName)
  4. getJdbcTypeName(int jdbcType)
  5. getJDBCTypeName(int value)
  6. getJDBCTypes()
  7. getLength(String format, String columnTypeName)
  8. getLong(Object object)
  9. getMBTileData(int column, int row, int zoomLevel, String jdbcConnectionString)