Java SQL Type getDefaultPrecision(int sqlType)

Here you can find the source of getDefaultPrecision(int sqlType)

Description

get Default Precision

License

Open Source License

Declaration

public static int getDefaultPrecision(int sqlType) 

Method Source Code

//package com.java2s;
/***********************************************************************************************************************
 * Copyright (c) 2009 Sybase, Inc. All rights reserved. This program and the accompanying materials are made available
 * under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * //from   w ww . ja v  a  2  s.  c om
 * Contributors: Sybase, Inc. - initial API and implementation
 **********************************************************************************************************************/

import java.sql.Types;

public class Main {
    public static int getDefaultPrecision(int sqlType) {
        switch (sqlType) {

        case Types.BIGINT:
            return 10;
        case Types.BINARY:
            return 1;
        case Types.BIT:
            return 1;
        case Types.BLOB:
            return 10;
        case Types.BOOLEAN:
            return 1;
        case Types.CHAR:
            return 1;
        case Types.DATE:
            return 10;
        case Types.DECIMAL:
            return 30;
        case Types.DOUBLE:
            return 15;
        case Types.FLOAT:
            return 10;
        case Types.INTEGER:
            return 10;
        case Types.NUMERIC:
            return 10;
        case Types.OTHER:
            return 10;
        case Types.REAL:
            return 7;
        case Types.SMALLINT:
            return 5;
        case Types.TIME:
            return 10;
        case Types.TIMESTAMP:
            return 23;
        case Types.TINYINT:
            return 3;
        case Types.VARCHAR:
            return 1;
        case Types.REF:
        case Types.STRUCT:
        case Types.VARBINARY:
        case Types.CLOB:
        case Types.DATALINK:
        case Types.DISTINCT:
        case Types.JAVA_OBJECT:
        case Types.LONGVARBINARY:
        case Types.LONGVARCHAR:
        case Types.NULL:
        default:
            return Integer.MAX_VALUE;
        }
    }
}

Related

  1. getColumnClass(int sqlType)
  2. getColumnType(Connection conn, String table, String column)
  3. getColumnType(String type)
  4. getConnection(String jdbcUrl, Properties properties)
  5. getDbDataType(Object o)
  6. getDefaultScale(int sqlType)
  7. getDefaultValue(Class type)
  8. getDoubleTypeString(Connection conn)
  9. getDoubleTypeString(Connection conn)