Example usage for java.sql Types DISTINCT

List of usage examples for java.sql Types DISTINCT

Introduction

In this page you can find the example usage for java.sql Types DISTINCT.

Prototype

int DISTINCT

To view the source code for java.sql Types DISTINCT.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type DISTINCT.

Usage

From source file:Main.java

public static String getCloverTypeFromJdbcType(int jdbcDataType) {
    switch (jdbcDataType) {
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        return "date";
    case Types.ARRAY:
    case Types.BINARY:
    case Types.DATALINK:
    case Types.BLOB:
    case Types.DISTINCT:
    case Types.JAVA_OBJECT:
    case Types.NULL:
    case Types.OTHER:
    case Types.REF:
    case Types.STRUCT:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        System.out.println("Outputting cbyte for Type: " + jdbcDataType);
        return "cbyte";
    case Types.BIT:
    case Types.BOOLEAN:
        return "boolean";
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.NUMERIC:
    case Types.REAL:
        return "numeric";
    case Types.INTEGER:
    case Types.SMALLINT:
        return "integer";
    case Types.BIGINT:
        return "long";
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.CLOB:
    case Types.LONGVARCHAR:
        return "string";
    }/*from  w  w  w . j a va2  s  .  c om*/
    System.out.println("Outputting string for unknown Type: " + jdbcDataType);
    return "string";
}

From source file:org.pentaho.reporting.engine.classic.core.modules.misc.tablemodel.TypeMapper.java

private static Class mapSQLType(final int t) {
    switch (t) {/*from w ww .j a va2 s.co  m*/
    case Types.ARRAY:
        return Object[].class;
    case Types.BIGINT:
        return Long.class;
    case Types.BINARY:
        return byteArrayClass;
    case Types.BIT:
        return Boolean.class;
    case Types.BLOB:
        return Blob.class;
    case Types.BOOLEAN: // Types.BOOLEAN was not part of JDK1.2.2
        return Boolean.class;
    case Types.CHAR:
        return String.class;
    case Types.CLOB:
        return Clob.class;
    case Types.DATALINK: // Types.DATALINK was not part of JDK 1.2.2
        return URL.class;
    case Types.DATE:
        return java.sql.Date.class;
    case Types.DECIMAL:
        return java.math.BigDecimal.class;
    case Types.DISTINCT:
        return Object.class;
    case Types.DOUBLE:
        return Double.class;
    case Types.FLOAT:
        return Double.class;
    case Types.INTEGER:
        return Integer.class;
    case Types.JAVA_OBJECT:
        return Object.class;
    case Types.LONGVARBINARY:
        return byteArrayClass;
    case Types.LONGVARCHAR:
        return String.class;
    case Types.NCLOB:
        return NClob.class;
    case Types.NULL:
        return Object.class;
    case Types.NUMERIC:
        return java.math.BigDecimal.class;
    case Types.NCHAR:
    case Types.NVARCHAR:
    case Types.LONGNVARCHAR:
        return String.class;
    case Types.OTHER:
        return Object.class;
    case Types.REAL:
        return Float.class;
    case Types.REF:
        return Ref.class;
    case Types.ROWID:
        return RowId.class;
    case Types.SMALLINT:
        return Short.class;
    case Types.STRUCT:
        return Struct.class;
    case Types.SQLXML:
        return SQLXML.class;
    case Types.TIME:
        return Time.class;
    case Types.TIMESTAMP:
        return Timestamp.class;
    case Types.TINYINT:
        return Byte.class;
    case Types.VARBINARY:
        return byteArrayClass;
    case Types.VARCHAR:
        return String.class;
    default:
        return Object.class;
    }
}

From source file:org.apache.openjpa.jdbc.schema.Schemas.java

/**
 * Return the SQL type name for the given {@link Types} constant.
 *//*from   w ww. ja  v  a  2  s  .  co m*/
public static String getJDBCName(int type) {
    switch (type) {
    case Types.ARRAY:
        return "array";
    case Types.BIGINT:
        return "bigint";
    case Types.BINARY:
        return "binary";
    case Types.BIT:
        return "bit";
    case Types.BLOB:
        return "blob";
    case Types.CHAR:
        return "char";
    case Types.CLOB:
        return "clob";
    case Types.DATE:
        return "date";
    case Types.DECIMAL:
        return "decimal";
    case Types.DISTINCT:
        return "distinct";
    case Types.DOUBLE:
        return "double";
    case Types.FLOAT:
        return "float";
    case Types.INTEGER:
        return "integer";
    case Types.JAVA_OBJECT:
        return "java_object";
    case Types.LONGVARBINARY:
        return "longvarbinary";
    case Types.LONGVARCHAR:
        return "longvarchar";
    case Types.NULL:
        return "null";
    case Types.NUMERIC:
        return "numeric";
    case Types.OTHER:
        return "other";
    case Types.REAL:
        return "real";
    case Types.REF:
        return "ref";
    case Types.SMALLINT:
        return "smallint";
    case Types.STRUCT:
        return "struct";
    case Types.TIME:
        return "time";
    case Types.TIMESTAMP:
        return "timestamp";
    case Types.TINYINT:
        return "tinyint";
    case Types.VARBINARY:
        return "varbinary";
    case Types.VARCHAR:
        return "varchar";
    default:
        return "unknown(" + type + ")";
    }
}

From source file:org.jumpmind.db.platform.h2.H2DdlBuilder.java

public H2DdlBuilder() {

    super(DatabaseNamesConstants.H2);

    databaseInfo.setNonPKIdentityColumnsSupported(false);
    databaseInfo.setIdentityOverrideAllowed(false);
    databaseInfo.setSystemForeignKeyIndicesAlwaysNonUnique(true);
    databaseInfo.setNullAsDefaultValueRequired(false);
    databaseInfo.addNativeTypeMapping(Types.ARRAY, "BINARY", Types.BINARY);
    databaseInfo.addNativeTypeMapping(Types.DISTINCT, "BINARY", Types.BINARY);
    databaseInfo.addNativeTypeMapping(Types.NULL, "BINARY", Types.BINARY);
    databaseInfo.addNativeTypeMapping(Types.REF, "BINARY", Types.BINARY);
    databaseInfo.addNativeTypeMapping(Types.STRUCT, "BINARY", Types.BINARY);
    databaseInfo.addNativeTypeMapping(Types.DATALINK, "BINARY", Types.BINARY);
    databaseInfo.addNativeTypeMapping(Types.BIT, "BOOLEAN", Types.BIT);
    databaseInfo.addNativeTypeMapping(Types.NUMERIC, "DECIMAL", Types.DECIMAL);
    databaseInfo.addNativeTypeMapping(Types.BINARY, "BINARY", Types.BINARY);
    databaseInfo.addNativeTypeMapping(Types.BLOB, "BLOB", Types.BLOB);
    databaseInfo.addNativeTypeMapping(Types.CLOB, "CLOB", Types.CLOB);
    databaseInfo.addNativeTypeMapping(Types.LONGVARCHAR, "VARCHAR(" + Integer.MAX_VALUE + ")", Types.VARCHAR);
    databaseInfo.addNativeTypeMapping(Types.FLOAT, "DOUBLE", Types.DOUBLE);
    databaseInfo.addNativeTypeMapping(Types.JAVA_OBJECT, "OTHER");

    databaseInfo.setDefaultSize(Types.CHAR, Integer.MAX_VALUE);
    databaseInfo.setDefaultSize(Types.VARCHAR, Integer.MAX_VALUE);
    databaseInfo.setDefaultSize(Types.BINARY, Integer.MAX_VALUE);
    databaseInfo.setDefaultSize(Types.VARBINARY, Integer.MAX_VALUE);

    databaseInfo.setNonBlankCharColumnSpacePadded(false);
    databaseInfo.setBlankCharColumnSpacePadded(false);
    databaseInfo.setCharColumnSpaceTrimmed(true);
    databaseInfo.setEmptyStringNulled(false);
    databaseInfo.setNullAsDefaultValueRequired(true);

}

From source file:com.espertech.esper.util.TestSQLTypeMapUtil.java

public void testMapping() {
    Map<Integer, Class> testData = new HashMap<Integer, Class>();
    testData.put(Types.CHAR, String.class);
    testData.put(Types.VARCHAR, String.class);
    testData.put(Types.LONGVARCHAR, String.class);
    testData.put(Types.NUMERIC, BigDecimal.class);
    testData.put(Types.DECIMAL, BigDecimal.class);
    testData.put(Types.BIT, Boolean.class);
    testData.put(Types.BOOLEAN, Boolean.class);
    testData.put(Types.TINYINT, Byte.class);
    testData.put(Types.SMALLINT, Short.class);
    testData.put(Types.INTEGER, Integer.class);
    testData.put(Types.BIGINT, Long.class);
    testData.put(Types.REAL, Float.class);
    testData.put(Types.FLOAT, Double.class);
    testData.put(Types.DOUBLE, Double.class);
    testData.put(Types.BINARY, byte[].class);
    testData.put(Types.VARBINARY, byte[].class);
    testData.put(Types.LONGVARBINARY, byte[].class);
    testData.put(Types.DATE, java.sql.Date.class);
    testData.put(Types.TIMESTAMP, java.sql.Timestamp.class);
    testData.put(Types.TIME, java.sql.Time.class);
    testData.put(Types.CLOB, java.sql.Clob.class);
    testData.put(Types.BLOB, java.sql.Blob.class);
    testData.put(Types.ARRAY, java.sql.Array.class);
    testData.put(Types.STRUCT, java.sql.Struct.class);
    testData.put(Types.REF, java.sql.Ref.class);
    testData.put(Types.DATALINK, java.net.URL.class);

    for (int type : testData.keySet()) {
        Class result = SQLTypeMapUtil.sqlTypeToClass(type, null);
        log.debug(".testMapping Mapping " + type + " to " + result.getSimpleName());
        assertEquals(testData.get(type), result);
    }// ww w  . j  a v  a2  s.c o m

    assertEquals(String.class, SQLTypeMapUtil.sqlTypeToClass(Types.JAVA_OBJECT, "java.lang.String"));
    assertEquals(String.class, SQLTypeMapUtil.sqlTypeToClass(Types.DISTINCT, "java.lang.String"));
}

From source file:com.espertech.esper.util.TestSQLTypeMapUtil.java

public void testMappingInvalid() {
    tryInvalid(Types.JAVA_OBJECT, null);
    tryInvalid(Types.JAVA_OBJECT, "xx");
    tryInvalid(Types.DISTINCT, null);
    tryInvalid(Integer.MAX_VALUE, "yy");
}

From source file:org.apache.ddlutils.platform.postgresql.PostgreSqlPlatform.java

/**
 * Creates a new platform instance./* ww  w .  j a va  2s  .c o m*/
 */
public PostgreSqlPlatform() {
    PlatformInfo info = getPlatformInfo();

    info.setPrimaryKeyColumnAutomaticallyRequired(true);
    // this is the default length though it might be changed when building PostgreSQL
    // in file src/include/postgres_ext.h
    info.setMaxIdentifierLength(31);

    info.addNativeTypeMapping(Types.ARRAY, "BYTEA", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.BINARY, "BYTEA", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.BIT, "BOOLEAN");
    info.addNativeTypeMapping(Types.BLOB, "BYTEA", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.BOOLEAN, "BOOLEAN", Types.BIT);
    info.addNativeTypeMapping(Types.CLOB, "TEXT", Types.LONGVARCHAR);
    info.addNativeTypeMapping(Types.DATALINK, "BYTEA", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.DECIMAL, "NUMERIC", Types.NUMERIC);
    info.addNativeTypeMapping(Types.DISTINCT, "BYTEA", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.DOUBLE, "DOUBLE PRECISION");
    info.addNativeTypeMapping(Types.FLOAT, "DOUBLE PRECISION", Types.DOUBLE);
    info.addNativeTypeMapping(Types.JAVA_OBJECT, "BYTEA", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.LONGVARBINARY, "BYTEA");
    info.addNativeTypeMapping(Types.LONGVARCHAR, "TEXT", Types.LONGVARCHAR);
    info.addNativeTypeMapping(Types.NULL, "BYTEA", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.OTHER, "BYTEA", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.REF, "BYTEA", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.STRUCT, "BYTEA", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.TINYINT, "SMALLINT", Types.SMALLINT);
    info.addNativeTypeMapping(Types.VARBINARY, "BYTEA", Types.LONGVARBINARY);

    info.setDefaultSize(Types.CHAR, 254);
    info.setDefaultSize(Types.VARCHAR, 254);

    // no support for specifying the size for these types (because they are mapped
    // to BYTEA which back-maps to BLOB)
    info.setHasSize(Types.BINARY, false);
    info.setHasSize(Types.VARBINARY, false);

    setSqlBuilder(new PostgreSqlBuilder(this));
    setModelReader(new PostgreSqlModelReader(this));
}

From source file:org.apache.openjpa.jdbc.schema.Schemas.java

/**
 * Return the {@link Types} constant for the given SQL type name.
 *//*  w w  w  . j a va2s . c o m*/
public static int getJDBCType(String name) {
    if ("array".equalsIgnoreCase(name))
        return Types.ARRAY;
    if ("bigint".equalsIgnoreCase(name))
        return Types.BIGINT;
    if ("binary".equalsIgnoreCase(name))
        return Types.BINARY;
    if ("bit".equalsIgnoreCase(name))
        return Types.BIT;
    if ("blob".equalsIgnoreCase(name))
        return Types.BLOB;
    if ("char".equalsIgnoreCase(name))
        return Types.CHAR;
    if ("clob".equalsIgnoreCase(name))
        return Types.CLOB;
    if ("date".equalsIgnoreCase(name))
        return Types.DATE;
    if ("decimal".equalsIgnoreCase(name))
        return Types.DECIMAL;
    if ("distinct".equalsIgnoreCase(name))
        return Types.DISTINCT;
    if ("double".equalsIgnoreCase(name))
        return Types.DOUBLE;
    if ("float".equalsIgnoreCase(name))
        return Types.FLOAT;
    if ("integer".equalsIgnoreCase(name))
        return Types.INTEGER;
    if ("java_object".equalsIgnoreCase(name))
        return Types.JAVA_OBJECT;
    if ("longvarbinary".equalsIgnoreCase(name))
        return Types.LONGVARBINARY;
    if ("longvarchar".equalsIgnoreCase(name))
        return Types.LONGVARCHAR;
    if ("null".equalsIgnoreCase(name))
        return Types.NULL;
    if ("numeric".equalsIgnoreCase(name))
        return Types.NUMERIC;
    if ("other".equalsIgnoreCase(name))
        return Types.OTHER;
    if ("real".equalsIgnoreCase(name))
        return Types.REAL;
    if ("ref".equalsIgnoreCase(name))
        return Types.REF;
    if ("smallint".equalsIgnoreCase(name))
        return Types.SMALLINT;
    if ("struct".equalsIgnoreCase(name))
        return Types.STRUCT;
    if ("time".equalsIgnoreCase(name))
        return Types.TIME;
    if ("timestamp".equalsIgnoreCase(name))
        return Types.TIMESTAMP;
    if ("tinyint".equalsIgnoreCase(name))
        return Types.TINYINT;
    if ("varbinary".equalsIgnoreCase(name))
        return Types.VARBINARY;
    if ("varchar".equalsIgnoreCase(name))
        return Types.VARCHAR;
    if (name == null || name.toLowerCase().startsWith("unknown"))
        return Types.OTHER;
    throw new IllegalArgumentException("name = " + name);
}

From source file:org.apache.ddlutils.platform.sybase.SybasePlatform.java

/**
 * Creates a new platform instance.// ww  w. ja  v  a  2s.  c o  m
 */
public SybasePlatform() {
    PlatformInfo info = getPlatformInfo();

    info.setMaxIdentifierLength(28);
    info.setNullAsDefaultValueRequired(true);
    info.setIdentityColumnAutomaticallyRequired(true);
    info.setMultipleIdentityColumnsSupported(false);
    info.setPrimaryKeyColumnsHaveToBeRequired(true);
    info.setCommentPrefix("/*");
    info.setCommentSuffix("*/");

    info.addNativeTypeMapping(Types.ARRAY, "IMAGE");
    // BIGINT is mapped back in the model reader
    info.addNativeTypeMapping(Types.BIGINT, "DECIMAL(19,0)");
    // we're not using the native BIT type because it is rather limited (cannot be NULL, cannot be indexed)
    info.addNativeTypeMapping(Types.BIT, "SMALLINT", Types.SMALLINT);
    info.addNativeTypeMapping(Types.BLOB, "IMAGE", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.BOOLEAN, "SMALLINT", Types.SMALLINT);
    info.addNativeTypeMapping(Types.CLOB, "TEXT", Types.LONGVARCHAR);
    info.addNativeTypeMapping(Types.DATALINK, "IMAGE", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.DATE, "DATETIME", Types.TIMESTAMP);
    info.addNativeTypeMapping(Types.DISTINCT, "IMAGE", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.DOUBLE, "DOUBLE PRECISION");
    info.addNativeTypeMapping(Types.FLOAT, "DOUBLE PRECISION", Types.DOUBLE);
    info.addNativeTypeMapping(Types.INTEGER, "INT");
    info.addNativeTypeMapping(Types.JAVA_OBJECT, "IMAGE", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.LONGVARBINARY, "IMAGE");
    info.addNativeTypeMapping(Types.LONGVARCHAR, "TEXT");
    info.addNativeTypeMapping(Types.NULL, "IMAGE", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.OTHER, "IMAGE", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.REF, "IMAGE", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.STRUCT, "IMAGE", Types.LONGVARBINARY);
    info.addNativeTypeMapping(Types.TIME, "DATETIME", Types.TIMESTAMP);
    info.addNativeTypeMapping(Types.TIMESTAMP, "DATETIME", Types.TIMESTAMP);
    info.addNativeTypeMapping(Types.TINYINT, "SMALLINT", Types.SMALLINT);

    info.setDefaultSize(Types.BINARY, 254);
    info.setDefaultSize(Types.VARBINARY, 254);
    info.setDefaultSize(Types.CHAR, 254);
    info.setDefaultSize(Types.VARCHAR, 254);

    setSqlBuilder(new SybaseBuilder(this));
    setModelReader(new SybaseModelReader(this));
}

From source file:org.apache.tajo.storage.jdbc.JdbcMetadataProviderBase.java

private TypeDesc convertDataType(ResultSet res) throws SQLException {
    final int typeId = res.getInt("DATA_TYPE");

    switch (typeId) {
    case Types.BOOLEAN:
        return new TypeDesc(newSimpleDataType(Type.BOOLEAN));

    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
        return new TypeDesc(newSimpleDataType(Type.INT4));

    case Types.DISTINCT: // sequence for postgresql
    case Types.BIGINT:
        return new TypeDesc(newSimpleDataType(Type.INT8));

    case Types.FLOAT:
        return new TypeDesc(newSimpleDataType(Type.FLOAT4));

    case Types.NUMERIC:
    case Types.DECIMAL:
    case Types.DOUBLE:
        return new TypeDesc(newSimpleDataType(Type.FLOAT8));

    case Types.DATE:
        return new TypeDesc(newSimpleDataType(Type.DATE));

    case Types.TIME:
        return new TypeDesc(newSimpleDataType(Type.TIME));

    case Types.TIMESTAMP:
        return new TypeDesc(newSimpleDataType(Type.TIMESTAMP));

    case Types.CHAR:
    case Types.NCHAR:
    case Types.VARCHAR:
    case Types.NVARCHAR:
    case Types.CLOB:
    case Types.NCLOB:
    case Types.LONGVARCHAR:
    case Types.LONGNVARCHAR:
        return new TypeDesc(newSimpleDataType(Type.TEXT));

    case Types.BINARY:
    case Types.VARBINARY:
    case Types.BLOB:
        return new TypeDesc(newSimpleDataType(Type.BLOB));

    default://  w  w w.ja v a  2 s. c o m
        throw SQLExceptionUtil.toSQLException(new UnsupportedDataTypeException(typeId + ""));
    }
}