Java SQL Type getNumberType(Integer precision, Integer scale)

Here you can find the source of getNumberType(Integer precision, Integer scale)

Description

getNumberType

License

Open Source License

Parameter

Parameter Description
precision Integer
scale Integer

Return

Integer

Declaration

private static Integer getNumberType(Integer precision, Integer scale) 

Method Source Code


//package com.java2s;
import java.sql.Types;

public class Main {
    /**//from w w w.  j  av a 2s.c o m
     * getNumberType
     * 
     * @param precision Integer
     * @param scale Integer
     * @return Integer
     */
    private static Integer getNumberType(Integer precision, Integer scale) {
        if (precision == null) {
            if (scale == null) {
                return Types.NUMERIC;
            } else if (scale == 0) {
                return Types.BIGINT;
            }
        } else if (scale == null || scale == 0) {
            if (precision == 1) {
                return Types.BIT;
            } else if (precision == 3) {
                return Types.TINYINT;
            } else if (precision == 5) {
                return Types.SMALLINT;
            } else if (precision <= 10) {
                return Types.INTEGER;
            } else if (precision <= 38) {
                return Types.BIGINT;
            }
        }
        return Types.NUMERIC;
    }
}

Related

  1. getJDBCTypeName(int value)
  2. getJdbcTypeNames()
  3. getJDBCTypes()
  4. getLength(String format, String columnTypeName)
  5. getNextQuotes(String lastQuotes, int lastType)
  6. getNumTypeWidth(int type)
  7. getObject(int sqlType, String value)
  8. getObjectType(Object param)
  9. getPartitionSizeValidationError(int colType, String column, String partitionSize)