Java SQL Type getStringFormat(int colType)

Here you can find the source of getStringFormat(int colType)

Description

get String Format

License

Apache License

Declaration

public static String getStringFormat(int colType) 

Method Source Code

//package com.java2s;
/*//w  w w.  j a  v a2s.c  o  m
 *   Licensed to the Apache Software Foundation (ASF) under one
 *   or more contributor license agreements.  See the NOTICE file
 *   distributed with this work for additional information
 *   regarding copyright ownership.  The ASF licenses this file
 *   to you 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.
 *
 */

import java.sql.Types;

public class Main {
    public static String getStringFormat(int colType) {
        //        case Types.BINARY:
        //        case Types.BIT:
        //        case Types.BLOB:
        //        case Types.BOOLEAN:
        //        case Types.CLOB:
        //        case Types.LONGVARBINARY:

        switch (colType) {
        case Types.DECIMAL:
        case Types.DOUBLE:
        case Types.FLOAT:
            return "%f";

            // date/time will be inserted into cassandra as a long
        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            return "%d";

        case Types.BIGINT:
        case Types.INTEGER:
        case Types.ROWID:
        case Types.NUMERIC:
        case Types.SMALLINT:
        case Types.TINYINT:
            return "%d";

        case Types.CHAR:
        case Types.LONGNVARCHAR:
        case Types.NCHAR:
        case Types.NVARCHAR:
        case Types.VARCHAR:
            return "%s";

        default:
            return "%s"; // lets assume everything as string, if it blow we will know
        }
    }
}

Related

  1. getSqlTypeName(int type)
  2. getSQLTypeName(Integer sqltypecode)
  3. getSQLTypePrecision(int sqlType)
  4. getSQLTypeRadix(int sqlType)
  5. getSqlValue(Object o)
  6. getTableTypes(DatabaseMetaData dbmd)
  7. getTinyIntTypeString(Connection conn)
  8. getType(int csqltype)
  9. getTypeforValue(int type)