Java SQL Type convertSQLtype2JavaClassName(int type)

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

Description

Translates a data type from an integer (java.sql.Types value) to a string that represents the corresponding class.

License

Open Source License

Parameter

Parameter Description
type The java.sql.Types value to convert to a string representation.

Return

The class name that corresponds to the given java.sql.Types value, or "java.lang.Object" if the type has no known mapping.

Declaration

public static String convertSQLtype2JavaClassName(int type) 

Method Source Code

//package com.java2s;
/*##############################################################################

 Copyright (C) 2011 HPCC Systems./*from  www. j  a  v a  2  s .  c o m*/

 All rights reserved. This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as
 published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program. If not, see <http://www.gnu.org/licenses/>.
 ############################################################################## */

import java.util.HashMap;

public class Main {
    private final static HashMap<Integer, String> mapSQLtypeCodeToJavaClass = new HashMap<Integer, String>();
    private final static String JAVA_OBJECT_TYPE_NAME = "java.lang.Object";

    /**
     * Translates a data type from an integer (java.sql.Types value) to a string
     * that represents the corresponding class.
     *
     * @param type
     *            The java.sql.Types value to convert to a string
     *            representation.
     * @return The class name that corresponds to the given java.sql.Types
     *         value, or "java.lang.Object" if the type has no known mapping.
     */
    public static String convertSQLtype2JavaClassName(int type) {
        if (mapSQLtypeCodeToJavaClass.containsKey(type))
            return mapSQLtypeCodeToJavaClass.get(type);
        else
            return JAVA_OBJECT_TYPE_NAME;
    }
}

Related

  1. convertBoolean(Object value, int srcType, int destType)
  2. convertKnownType(Object one, Class to)
  3. convertNumeric(Object value, int srcType, int destType)
  4. convertOracleValue(Object value, int type)
  5. convertParam(Object oValue, Class cType, String sFieldName)
  6. convertStringToType(String type)
  7. convertTemporal(Object value, int srcType, int destType)
  8. convertToJDBCType(String talendType)
  9. convertToProperty(Object value)