Java SQL Type columnClassName(int columnType)

Here you can find the source of columnClassName(int columnType)

Description

column Class Name

License

Apache License

Declaration

static String columnClassName(int columnType) throws SQLException 

Method Source Code

//package com.java2s;
/*//from  w w  w  .  j a  v a2  s . c o m
 * #%L
 * Grill client
 * %%
 * Copyright (C) 2014 Inmobi
 * %%
 * 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.
 * #L%
 */

import java.math.BigInteger;

import java.sql.Date;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;

public class Main {
    static String columnClassName(int columnType) throws SQLException {
        switch (columnType) {
        case Types.BOOLEAN:
            return Boolean.class.getName();
        case Types.CHAR:
        case Types.VARCHAR:
            return String.class.getName();
        case Types.TINYINT:
            return Byte.class.getName();
        case Types.SMALLINT:
            return Short.class.getName();
        case Types.INTEGER:
            return Integer.class.getName();
        case Types.BIGINT:
            return Long.class.getName();
        case Types.DATE:
            return Date.class.getName();
        case Types.FLOAT:
            return Float.class.getName();
        case Types.DOUBLE:
            return Double.class.getName();
        case Types.TIMESTAMP:
            return Timestamp.class.getName();
        case Types.DECIMAL:
            return BigInteger.class.getName();
        case Types.BINARY:
            return byte[].class.getName();
        case Types.JAVA_OBJECT:
        case Types.ARRAY:
        case Types.STRUCT:
            return String.class.getName();
        default:
            throw new SQLException("Invalid column type: " + columnType);
        }
    }
}

Related

  1. addParameter(PreparedStatement smt, int index, Object value)
  2. adjustLevel(String attribute, int type)
  3. callPro2(String sql, String[] inparameters, Integer[] outparameters)
  4. columnDisplaySize(int columnType)
  5. columnPrecision(int columnType)
  6. columnScale(int columnType)
  7. columnTypesDiffer(int t1, int t2)