Java Code Examples for java.sql.Types#DISTINCT

The following examples show how to use java.sql.Types#DISTINCT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlServerColumnMetadataReader.java    From virtual-schemas with MIT License 6 votes vote down vote up
@Override
public DataType mapJdbcType(final JdbcTypeDescription jdbcTypeDescription) {
    switch (jdbcTypeDescription.getJdbcType()) {
    case Types.VARCHAR:
        return mapVarChar(jdbcTypeDescription);
    case Types.TIME:
    case Types.TIME_WITH_TIMEZONE:
        return DataType.createVarChar(SQLSERVER_TIMESTAMP_TEXT_SIZE, DataType.ExaCharset.UTF8);
    case Types.NUMERIC:
        return mapJdbcTypeNumericToDecimalWithFallbackToDouble(jdbcTypeDescription);
    case Types.OTHER:
    case Types.SQLXML:
        return DataType.createVarChar(SqlServerSqlDialect.MAX_SQLSERVER_VARCHAR_SIZE, DataType.ExaCharset.UTF8);
    case Types.CLOB:
        return DataType.createVarChar(SqlServerSqlDialect.MAX_SQLSERVER_CLOB_SIZE, DataType.ExaCharset.UTF8);
    case Types.BLOB:
        return mapBlob(jdbcTypeDescription);
    case Types.VARBINARY:
    case Types.BINARY:
    case Types.DISTINCT:
        return DataType.createVarChar(SQLSERVER_BLOB_SIZE, DataType.ExaCharset.UTF8);
    default:
        return super.mapJdbcType(jdbcTypeDescription);
    }
}
 
Example 2
Source File: TypeValidator.java    From sql-layer with GNU Affero General Public License v3.0 6 votes vote down vote up
public static boolean isSupportedForJoin(TClass tclass1, TClass tclass2) {
    if (tclass1 == tclass2) {
        return true;
    }
    int jt1 = baseJoinType(tclass1);
    int jt2 = baseJoinType(tclass2);
    if (jt1 == jt2) {
        switch (jt1) {
        case Types.DISTINCT:
        case Types.JAVA_OBJECT:
        case Types.OTHER:
        case Types.STRUCT:
            return false;
        default:
            return true;
        }
    }
    else {
        return false;
    }
}
 
Example 3
Source File: JDBCTypeMapper.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Class getJavaType(short jdbcType) {
	switch(jdbcType) {
		case Types.ARRAY: 			return java.sql.Array.class;
		case Types.BIGINT: 			return java.lang.Long.class;
		case Types.BINARY: 			return java.lang.Byte[].class;
		case Types.BIT: 			return java.lang.Boolean.class;
		case Types.BLOB: 			return java.sql.Blob.class;
		case Types.CHAR: 			return java.lang.String.class;
		case Types.CLOB: 			return java.sql.Clob.class;
		case Types.DATE: 			return java.sql.Date.class;
		case Types.DECIMAL: 		return java.math.BigDecimal.class;
		case Types.DISTINCT: 		return java.lang.Object.class;
		case Types.DOUBLE: 			return java.lang.Double.class;
		case Types.FLOAT: 			return java.lang.Double.class;
		case Types.INTEGER: 		return java.lang.Integer.class;
		case Types.JAVA_OBJECT: 	return java.lang.Object.class;
		case Types.LONGVARBINARY: 	return java.lang.Byte[].class;
		case Types.LONGVARCHAR: 	return java.lang.String.class;
		case Types.NULL: 			return java.lang.Object.class;
		case Types.NUMERIC: 		return java.math.BigDecimal.class;
		case Types.OTHER: 			return java.lang.Object.class;
		case Types.REAL: 			return java.lang.Float.class;
		case Types.REF: 			return java.sql.Ref.class;
		case Types.SMALLINT: 		return java.lang.Short.class;
		case Types.STRUCT: 			return java.sql.Struct.class;
		case Types.TIME: 			return java.sql.Time.class;
		case Types.TIMESTAMP: 		return java.sql.Timestamp.class;
		case Types.TINYINT: 		return java.lang.Byte.class;
		case Types.VARBINARY: 		return java.lang.Byte[].class;
		case Types.VARCHAR: 		return java.lang.String.class;
		default: 					return null;	
	}
}
 
Example 4
Source File: TypesTranslator.java    From sql-layer with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * This does not return null
 * @throws com.foundationdb.server.error.UnsupportedColumnDataTypeException if an appropriate TClass can't be found
 * @throws com.foundationdb.server.error.UnsupportedDataTypeException if an appropriate TClass can't be found
 */
public TClass typeClassForJDBCType(int jdbcType,
                                   String schemaName, String tableName, String columnName) {
    switch (jdbcType) {
    case Types.BLOB:
        return AkBlob.INSTANCE;
    case Types.BOOLEAN:
        return AkBool.INSTANCE;
    case Types.ARRAY:
    case Types.DATALINK:
    case Types.DISTINCT:
    case Types.JAVA_OBJECT:
    case Types.NULL:
    case Types.OTHER:
    case Types.REF:
    case Types.ROWID:
    case Types.STRUCT:
    default:
        if (columnName != null) {
            throw new UnsupportedColumnDataTypeException(schemaName, tableName, columnName,
                                                         jdbcTypeName(jdbcType));
        }
        else {
            throw new UnsupportedDataTypeException(jdbcTypeName(jdbcType));
        }
    }        
}
 
Example 5
Source File: JDBCTypeMapper.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Class getJavaType(short jdbcType) {
	switch (jdbcType) {
	case Types.ARRAY:
		return java.sql.Array.class;
	case Types.BIGINT:
		return java.lang.Long.class;
	case Types.BINARY:
		return java.lang.Byte[].class;
	case Types.BIT:
		return java.lang.Boolean.class;
	case Types.BLOB:
		return java.sql.Blob.class;
	case Types.CHAR:
		return java.lang.String.class;
	case Types.CLOB:
		return java.sql.Clob.class;
	case Types.DATE:
		return java.sql.Date.class;
	case Types.DECIMAL:
		return java.math.BigDecimal.class;
	case Types.DISTINCT:
		return java.lang.Object.class;
	case Types.DOUBLE:
		return java.lang.Double.class;
	case Types.FLOAT:
		return java.lang.Double.class;
	case Types.INTEGER:
		return java.lang.Integer.class;
	case Types.JAVA_OBJECT:
		return java.lang.Object.class;
	case Types.LONGVARBINARY:
		return java.lang.Byte[].class;
	case Types.LONGVARCHAR:
		return java.lang.String.class;
	case Types.NULL:
		return java.lang.Object.class;
	case Types.NUMERIC:
		return java.math.BigDecimal.class;
	case Types.OTHER:
		return java.lang.Object.class;
	case Types.REAL:
		return java.lang.Float.class;
	case Types.REF:
		return java.sql.Ref.class;
	case Types.SMALLINT:
		return java.lang.Short.class;
	case Types.STRUCT:
		return java.sql.Struct.class;
	case Types.TIME:
		return java.sql.Time.class;
	case Types.TIMESTAMP:
		return java.sql.Timestamp.class;
	case Types.TINYINT:
		return java.lang.Byte.class;
	case Types.VARBINARY:
		return java.lang.Byte[].class;
	case Types.VARCHAR:
		return java.lang.String.class;
	default:
		return null;
	}
}
 
Example 6
Source File: ParseUtil.java    From datacollector with Apache License 2.0 4 votes vote down vote up
public static Field generateField(
    String column,
    String columnValue,
    int columnType,
    DateTimeColumnHandler dateTimeColumnHandler
) throws StageException {
  Field field;
  // All types as of JDBC 2.0 are here:
  // https://docs.oracle.com/javase/8/docs/api/constant-values.html#java.sql.Types.ARRAY
  // Good source of recommended mappings is here:
  // http://www.cs.mun.ca/java-api-1.5/guide/jdbc/getstart/mapping.html
  switch (columnType) {
    case Types.BIGINT:
      field = Field.create(Field.Type.LONG, columnValue);
      break;
    case Types.BINARY:
    case Types.LONGVARBINARY:
    case Types.VARBINARY:
      field = Field.create(Field.Type.BYTE_ARRAY, RawTypeHandler.parseRaw(column, columnValue, columnType));
      break;
    case Types.BIT:
    case Types.BOOLEAN:
      field = Field.create(Field.Type.BOOLEAN, columnValue);
      break;
    case Types.CHAR:
    case Types.LONGNVARCHAR:
    case Types.LONGVARCHAR:
    case Types.NCHAR:
    case Types.NVARCHAR:
    case Types.VARCHAR:
      field = Field.create(Field.Type.STRING, columnValue);
      break;
    case Types.DECIMAL:
    case Types.NUMERIC:
      field = Field.create(Field.Type.DECIMAL, columnValue);
      break;
    case Types.DOUBLE:
      field = Field.create(Field.Type.DOUBLE, columnValue);
      break;
    case Types.FLOAT:
    case Types.REAL:
      field = Field.create(Field.Type.FLOAT, columnValue);
      break;
    case Types.INTEGER:
      field = Field.create(Field.Type.INTEGER, columnValue);
      break;
    case Types.SMALLINT:
    case Types.TINYINT:
      field = Field.create(Field.Type.SHORT, columnValue);
      break;
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
      field = dateTimeColumnHandler.getDateTimeStampField(column, columnValue, columnType);
      break;
    case Types.TIMESTAMP_WITH_TIMEZONE:
    case TIMESTAMP_TZ_TYPE:
      field = dateTimeColumnHandler.getTimestampWithTimezoneField(columnValue);
      break;
    case TIMESTAMP_LTZ_TYPE:
      field = dateTimeColumnHandler.getTimestampWithLocalTimezone(columnValue);
      break;
    case Types.ROWID:
    case Types.CLOB:
    case Types.NCLOB:
    case Types.BLOB:
    case Types.ARRAY:
    case Types.DATALINK:
    case Types.DISTINCT:
    case Types.JAVA_OBJECT:
    case Types.NULL:
    case Types.OTHER:
    case Types.REF:
    case Types.REF_CURSOR:
    case Types.SQLXML:
    case Types.STRUCT:
    case Types.TIME_WITH_TIMEZONE:
    default:
      throw new UnsupportedFieldTypeException(column, columnValue, columnType);
  }
  return field;
}
 
Example 7
Source File: Converters.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Get {@link GFXDType} for given JDBC {@link Types}.
 */
public static GFXDType getThriftSQLType(int jdbcType) {
  switch (jdbcType) {
    case Types.ARRAY:
      return GFXDType.ARRAY;
    case Types.BIGINT:
      return GFXDType.BIGINT;
    case Types.BINARY:
      return GFXDType.BINARY;
    case Types.BIT:
      return GFXDType.BOOLEAN;
    case Types.BLOB:
      return GFXDType.BLOB;
    case Types.BOOLEAN:
      return GFXDType.BOOLEAN;
    case Types.CHAR:
      return GFXDType.CHAR;
    case Types.CLOB:
      return GFXDType.CLOB;
    case Types.DATALINK:
      return GFXDType.DATALINK;
    case Types.DATE:
      return GFXDType.DATE;
    case Types.DECIMAL:
      return GFXDType.DECIMAL;
    case Types.DISTINCT:
      return GFXDType.DISTINCT;
    case Types.DOUBLE:
      return GFXDType.DOUBLE;
    case Types.FLOAT:
      return GFXDType.FLOAT;
    case Types.INTEGER:
      return GFXDType.INTEGER;
    case Types.JAVA_OBJECT:
      return GFXDType.JAVA_OBJECT;
    case TYPE_JSON_OBJECT:
      return GFXDType.JSON_OBJECT;
    case Types.LONGNVARCHAR:
      return GFXDType.LONGNVARCHAR;
    case Types.LONGVARBINARY:
      return GFXDType.LONGVARBINARY;
    case Types.LONGVARCHAR:
      return GFXDType.LONGVARCHAR;
    case Types.NCHAR:
      return GFXDType.NCHAR;
    case Types.NCLOB:
      return GFXDType.NCLOB;
    case Types.NULL:
      return GFXDType.NULLTYPE;
    case Types.NUMERIC:
      return GFXDType.DECIMAL;
    case Types.NVARCHAR:
      return GFXDType.NVARCHAR;
    case Types.OTHER:
      return GFXDType.OTHER;
    case TYPE_PDX_OBJECT:
      return GFXDType.PDX_OBJECT;
    case Types.REAL:
      return GFXDType.REAL;
    case Types.REF:
      return GFXDType.REF;
    case Types.ROWID:
      return GFXDType.ROWID;
    case Types.SMALLINT:
      return GFXDType.SMALLINT;
    case Types.SQLXML:
      return GFXDType.SQLXML;
    case Types.STRUCT:
      return GFXDType.STRUCT;
    case Types.TIME:
      return GFXDType.TIME;
    case Types.TIMESTAMP:
      return GFXDType.TIMESTAMP;
    case Types.TINYINT:
      return GFXDType.TINYINT;
    case Types.VARBINARY:
      return GFXDType.VARBINARY;
    case Types.VARCHAR:
      return GFXDType.VARCHAR;
    default:
      return GFXDType.OTHER;
  }
}
 
Example 8
Source File: Converters.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Get JDBC {@link Types} type for given {@link GFXDType}.
 */
public static int getJdbcType(GFXDType type) {
  switch (type) {
    case ARRAY:
      return Types.ARRAY;
    case BIGINT:
      return Types.BIGINT;
    case BINARY:
      return Types.BINARY;
    case BLOB:
      return Types.BLOB;
    case BOOLEAN:
      return Types.BOOLEAN;
    case CHAR:
      return Types.CHAR;
    case CLOB:
      return Types.CLOB;
    case DATALINK:
      return Types.DATALINK;
    case DATE:
      return Types.DATE;
    case DECIMAL:
      return Types.DECIMAL;
    case DISTINCT:
      return Types.DISTINCT;
    case DOUBLE:
      return Types.DOUBLE;
    case FLOAT:
      return Types.FLOAT;
    case INTEGER:
      return Types.INTEGER;
    case JAVA_OBJECT:
      return Types.JAVA_OBJECT;
    case JSON_OBJECT:
      return TYPE_JSON_OBJECT;
    case LONGNVARCHAR:
      return Types.LONGNVARCHAR;
    case LONGVARBINARY:
      return Types.LONGVARBINARY;
    case LONGVARCHAR:
      return Types.LONGVARCHAR;
    case NCHAR:
      return Types.NCHAR;
    case NCLOB:
      return Types.NCLOB;
    case NULLTYPE:
      return Types.NULL;
    case NVARCHAR:
      return Types.NVARCHAR;
    case OTHER:
      return Types.OTHER;
    case PDX_OBJECT:
      return TYPE_PDX_OBJECT;
    case REAL:
      return Types.REAL;
    case REF:
      return Types.REF;
    case ROWID:
      return Types.ROWID;
    case SMALLINT:
      return Types.SMALLINT;
    case SQLXML:
      return Types.SQLXML;
    case STRUCT:
      return Types.STRUCT;
    case TIME:
      return Types.TIME;
    case TIMESTAMP:
      return Types.TIMESTAMP;
    case TINYINT:
      return Types.TINYINT;
    case VARBINARY:
      return Types.VARBINARY;
    case VARCHAR:
      return Types.VARCHAR;
    default:
      return Types.OTHER;
  }
}
 
Example 9
Source File: ResultSetToKVStoreSerializer.java    From AILibs with GNU Affero General Public License v3.0 4 votes vote down vote up
public IKVStore serializeRow(final ResultSet values, final String[] columnNames, final int[] columnTypes) throws SQLException, ResultSetSerializerException {
	KVStore store = new KVStore();

	for (int i = 0; i < columnNames.length; i++) {
		String fieldName = columnNames[i];

		switch (columnTypes[i]) {
		case Types.INTEGER:
			store.put(fieldName, values.getInt(i + 1));
			break;
		case Types.BIGINT:
			store.put(fieldName, values.getLong(i + 1));
			break;
		case Types.DECIMAL:
		case Types.NUMERIC:
			store.put(fieldName, values.getBigDecimal(i + 1));
			break;
		case Types.FLOAT:
		case Types.REAL:
		case Types.DOUBLE:
			store.put(fieldName, values.getDouble(i + 1));
			break;
		case Types.NVARCHAR:
		case Types.VARCHAR:
		case Types.LONGNVARCHAR:
		case Types.LONGVARCHAR:
			store.put(fieldName, values.getString(i + 1));
			break;
		case Types.BOOLEAN:
		case Types.BIT:
			store.put(fieldName, values.getBoolean(i + 1));
			break;
		case Types.BINARY:
		case Types.VARBINARY:
		case Types.LONGVARBINARY:
			store.put(fieldName, values.getByte(i + 1));
			break;
		case Types.TINYINT:
		case Types.SMALLINT:
			store.put(fieldName, values.getShort(i + 1));
			break;
		case Types.DATE:
			store.put(fieldName, values.getDate(i + 1));
			break;
		case Types.TIMESTAMP:
			store.put(fieldName, values.getTime(i + 1));
			break;

		case Types.BLOB:
			store.put(fieldName, values.getBlob(i));
			break;

		case Types.CLOB:
			store.put(fieldName, values.getClob(i));
			break;

		case Types.ARRAY:
			throw new ResultSetSerializerException("ResultSetSerializer not yet implemented for SQL type ARRAY");

		case Types.STRUCT:
			throw new ResultSetSerializerException("ResultSetSerializer not yet implemented for SQL type STRUCT");

		case Types.DISTINCT:
			throw new ResultSetSerializerException("ResultSetSerializer not yet implemented for SQL type DISTINCT");

		case Types.REF:
			throw new ResultSetSerializerException("ResultSetSerializer not yet implemented for SQL type REF");

		case Types.JAVA_OBJECT:
		default:
			store.put(fieldName, values.getObject(i + 1));
			break;
		}

		if (values.wasNull()) {
			store.put(fieldName, null);
		}
	}
	return store;
}
 
Example 10
Source File: SqlServerColumnMetadataReaderTest.java    From virtual-schemas with MIT License 4 votes vote down vote up
@ValueSource(ints = { Types.BLOB, Types.VARBINARY, Types.BINARY, Types.DISTINCT })
@ParameterizedTest
void testMapJdbcTypeBlob(final int type) {
    final DataType jdbcType = mapJdbcType(type);
    assertThat(jdbcType, equalTo(DataType.createVarChar(SQLSERVER_BLOB_SIZE, DataType.ExaCharset.UTF8)));
}
 
Example 11
Source File: AvaticaSite.java    From calcite-avatica with Apache License 2.0 4 votes vote down vote up
public void setObject(Object x, int targetSqlType) {
  if (x == null || Types.NULL == targetSqlType) {
    setNull(targetSqlType);
    return;
  }
  switch (targetSqlType) {
  case Types.CLOB:
  case Types.DATALINK:
  case Types.NCLOB:
  case Types.OTHER:
  case Types.REF:
  case Types.SQLXML:
  case Types.STRUCT:
    throw notImplemented();
  case Types.ARRAY:
    setArray(toArray(x));
    break;
  case Types.BIGINT:
    setLong(toLong(x));
    break;
  case Types.BINARY:
  case Types.LONGVARBINARY:
  case Types.VARBINARY:
    setBytes(toBytes(x));
    break;
  case Types.BIT:
  case Types.BOOLEAN:
    setBoolean(toBoolean(x));
    break;
  case Types.BLOB:
    if (x instanceof Blob) {
      setBlob((Blob) x);
      break;
    } else if (x instanceof InputStream) {
      setBlob((InputStream) x);
    }
    throw unsupportedCast(x.getClass(), Blob.class);
  case Types.DATE:
    setDate(toDate(x), calendar);
    break;
  case Types.DECIMAL:
  case Types.NUMERIC:
    setBigDecimal(toBigDecimal(x));
    break;
  case Types.DISTINCT:
    throw notImplemented();
  case Types.DOUBLE:
  case Types.FLOAT: // yes really; SQL FLOAT is up to 8 bytes
    setDouble(toDouble(x));
    break;
  case Types.INTEGER:
    setInt(toInt(x));
    break;
  case Types.JAVA_OBJECT:
    setObject(x);
    break;
  case Types.LONGNVARCHAR:
  case Types.LONGVARCHAR:
  case Types.NVARCHAR:
  case Types.VARCHAR:
  case Types.CHAR:
  case Types.NCHAR:
    setString(toString(x));
    break;
  case Types.REAL:
    setFloat(toFloat(x));
    break;
  case Types.ROWID:
    if (x instanceof RowId) {
      setRowId((RowId) x);
      break;
    }
    throw unsupportedCast(x.getClass(), RowId.class);
  case Types.SMALLINT:
    setShort(toShort(x));
    break;
  case Types.TIME:
    setTime(toTime(x), calendar);
    break;
  case Types.TIMESTAMP:
    setTimestamp(toTimestamp(x), calendar);
    break;
  case Types.TINYINT:
    setByte(toByte(x));
    break;
  default:
    throw notImplemented();
  }
}
 
Example 12
Source File: JDBCTypeMapper.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static String getModelType(short jdbcType) {
	switch (jdbcType) {
	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 null;
	}
}
 
Example 13
Source File: JdbcTypesUtils.java    From pxf with Apache License 2.0 4 votes vote down vote up
public static String getSqlTypeName(int type) {
	switch (type) {
	case Types.BIT:
		return "BIT";
	case Types.TINYINT:
		return "TINYINT";
	case Types.SMALLINT:
		return "SMALLINT";
	case Types.INTEGER:
		return "INTEGER";
	case Types.BIGINT:
		return "BIGINT";
	case Types.FLOAT:
		return "FLOAT";
	case Types.REAL:
		return "REAL";
	case Types.DOUBLE:
		return "DOUBLE";
	case Types.NUMERIC:
		return "NUMERIC";
	case Types.DECIMAL:
		return "DECIMAL";
	case Types.CHAR:
		return "CHAR";
	case Types.VARCHAR:
		return "VARCHAR";
	case Types.LONGVARCHAR:
		return "LONGVARCHAR";
	case Types.DATE:
		return "DATE";
	case Types.TIME:
		return "TIME";
	case Types.TIMESTAMP:
		return "TIMESTAMP";
	case Types.BINARY:
		return "BINARY";
	case Types.VARBINARY:
		return "VARBINARY";
	case Types.LONGVARBINARY:
		return "LONGVARBINARY";
	case Types.NULL:
		return "NULL";
	case Types.OTHER:
		return "OTHER";
	case Types.JAVA_OBJECT:
		return "JAVA_OBJECT";
	case Types.DISTINCT:
		return "DISTINCT";
	case Types.STRUCT:
		return "STRUCT";
	case Types.ARRAY:
		return "ARRAY";
	case Types.BLOB:
		return "BLOB";
	case Types.CLOB:
		return "CLOB";
	case Types.REF:
		return "REF";
	case Types.DATALINK:
		return "DATALINK";
	case Types.BOOLEAN:
		return "BOOLEAN";
	case Types.ROWID:
		return "ROWID";
	case Types.NCHAR:
		return "NCHAR";
	case Types.NVARCHAR:
		return "NVARCHAR";
	case Types.LONGNVARCHAR:
		return "LONGNVARCHAR";
	case Types.NCLOB:
		return "NCLOB";
	case Types.SQLXML:
		return "SQLXML";
	}

	return "?";
}
 
Example 14
Source File: JDBCTypeMapper.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static String getModelType(short jdbcType) {
	switch (jdbcType) {
	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";
	case Types.NVARCHAR:
		return "NVARCHAR";
	default:
		return null;
	}
}
 
Example 15
Source File: JDBCTypeMapper.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Class getJavaType(short jdbcType) {
	switch (jdbcType) {
	case Types.ARRAY:
		return java.sql.Array.class;
	case Types.BIGINT:
		return java.lang.Long.class;
	case Types.BINARY:
		return java.lang.Byte[].class;
	case Types.BIT:
		return java.lang.Boolean.class;
	case Types.BLOB:
		return java.sql.Blob.class;
	case Types.CHAR:
		return java.lang.String.class;
	case Types.CLOB:
		return java.sql.Clob.class;
	case Types.DATE:
		return java.sql.Date.class;
	case Types.DECIMAL:
		return java.math.BigDecimal.class;
	case Types.DISTINCT:
		return java.lang.Object.class;
	case Types.DOUBLE:
		return java.lang.Double.class;
	case Types.FLOAT:
		return java.lang.Double.class;
	case Types.INTEGER:
		return java.lang.Integer.class;
	case Types.JAVA_OBJECT:
		return java.lang.Object.class;
	case Types.LONGVARBINARY:
		return java.lang.Byte[].class;
	case Types.LONGVARCHAR:
		return java.lang.String.class;
	case Types.NULL:
		return java.lang.Object.class;
	case Types.NUMERIC:
		return java.math.BigDecimal.class;
	case Types.OTHER:
		return java.lang.Object.class;
	case Types.REAL:
		return java.lang.Float.class;
	case Types.REF:
		return java.sql.Ref.class;
	case Types.SMALLINT:
		return java.lang.Short.class;
	case Types.STRUCT:
		return java.sql.Struct.class;
	case Types.TIME:
		return java.sql.Time.class;
	case Types.TIMESTAMP:
		return java.sql.Timestamp.class;
	case Types.TINYINT:
		return java.lang.Byte.class;
	case Types.VARBINARY:
		return java.lang.Byte[].class;
	case Types.VARCHAR:
		return java.lang.String.class;
	case Types.NVARCHAR:
		return java.lang.String.class;
	default:
		return null;
	}
}
 
Example 16
Source File: Converters.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Get {@link GFXDType} for given JDBC {@link Types}.
 */
public static GFXDType getThriftSQLType(int jdbcType) {
  switch (jdbcType) {
    case Types.ARRAY:
      return GFXDType.ARRAY;
    case Types.BIGINT:
      return GFXDType.BIGINT;
    case Types.BINARY:
      return GFXDType.BINARY;
    case Types.BIT:
      return GFXDType.BOOLEAN;
    case Types.BLOB:
      return GFXDType.BLOB;
    case Types.BOOLEAN:
      return GFXDType.BOOLEAN;
    case Types.CHAR:
      return GFXDType.CHAR;
    case Types.CLOB:
      return GFXDType.CLOB;
    case Types.DATALINK:
      return GFXDType.DATALINK;
    case Types.DATE:
      return GFXDType.DATE;
    case Types.DECIMAL:
      return GFXDType.DECIMAL;
    case Types.DISTINCT:
      return GFXDType.DISTINCT;
    case Types.DOUBLE:
      return GFXDType.DOUBLE;
    case Types.FLOAT:
      return GFXDType.FLOAT;
    case Types.INTEGER:
      return GFXDType.INTEGER;
    case Types.JAVA_OBJECT:
      return GFXDType.JAVA_OBJECT;
    case TYPE_JSON_OBJECT:
      return GFXDType.JSON_OBJECT;
    case Types.LONGNVARCHAR:
      return GFXDType.LONGNVARCHAR;
    case Types.LONGVARBINARY:
      return GFXDType.LONGVARBINARY;
    case Types.LONGVARCHAR:
      return GFXDType.LONGVARCHAR;
    case Types.NCHAR:
      return GFXDType.NCHAR;
    case Types.NCLOB:
      return GFXDType.NCLOB;
    case Types.NULL:
      return GFXDType.NULLTYPE;
    case Types.NUMERIC:
      return GFXDType.DECIMAL;
    case Types.NVARCHAR:
      return GFXDType.NVARCHAR;
    case Types.OTHER:
      return GFXDType.OTHER;
    case TYPE_PDX_OBJECT:
      return GFXDType.PDX_OBJECT;
    case Types.REAL:
      return GFXDType.REAL;
    case Types.REF:
      return GFXDType.REF;
    case Types.ROWID:
      return GFXDType.ROWID;
    case Types.SMALLINT:
      return GFXDType.SMALLINT;
    case Types.SQLXML:
      return GFXDType.SQLXML;
    case Types.STRUCT:
      return GFXDType.STRUCT;
    case Types.TIME:
      return GFXDType.TIME;
    case Types.TIMESTAMP:
      return GFXDType.TIMESTAMP;
    case Types.TINYINT:
      return GFXDType.TINYINT;
    case Types.VARBINARY:
      return GFXDType.VARBINARY;
    case Types.VARCHAR:
      return GFXDType.VARCHAR;
    default:
      return GFXDType.OTHER;
  }
}
 
Example 17
Source File: SqoopHCatUtilities.java    From aliyun-maxcompute-data-collectors with Apache License 2.0 4 votes vote down vote up
public static String sqlTypeString(int sqlType) {
  switch (sqlType) {
    case Types.BIT:
      return "BIT";
    case Types.TINYINT:
      return "TINYINT";
    case Types.SMALLINT:
      return "SMALLINT";
    case Types.INTEGER:
      return "INTEGER";
    case Types.BIGINT:
      return "BIGINT";
    case Types.FLOAT:
      return "FLOAT";
    case Types.REAL:
      return "REAL";
    case Types.DOUBLE:
      return "DOUBLE";
    case Types.NUMERIC:
      return "NUMERIC";
    case Types.DECIMAL:
      return "DECIMAL";
    case Types.CHAR:
      return "CHAR";
    case Types.VARCHAR:
      return "VARCHAR";
    case Types.LONGVARCHAR:
      return "LONGVARCHAR";
    case Types.DATE:
      return "DATE";
    case Types.TIME:
      return "TIME";
    case Types.TIMESTAMP:
      return "TIMESTAMP";
    case Types.BINARY:
      return "BINARY";
    case Types.VARBINARY:
      return "VARBINARY";
    case Types.LONGVARBINARY:
      return "LONGVARBINARY";
    case Types.NULL:
      return "NULL";
    case Types.OTHER:
      return "OTHER";
    case Types.JAVA_OBJECT:
      return "JAVA_OBJECT";
    case Types.DISTINCT:
      return "DISTINCT";
    case Types.STRUCT:
      return "STRUCT";
    case Types.ARRAY:
      return "ARRAY";
    case Types.BLOB:
      return "BLOB";
    case Types.CLOB:
      return "CLOB";
    case Types.REF:
      return "REF";
    case Types.DATALINK:
      return "DATALINK";
    case Types.BOOLEAN:
      return "BOOLEAN";
    case Types.ROWID:
      return "ROWID";
    case Types.NCHAR:
      return "NCHAR";
    case Types.NVARCHAR:
      return "NVARCHAR";
    case Types.LONGNVARCHAR:
      return "LONGNVARCHAR";
    case Types.NCLOB:
      return "NCLOB";
    case Types.SQLXML:
      return "SQLXML";
    default:
      return "<UNKNOWN>";
  }
}
 
Example 18
Source File: TeradataDialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String getSelectClauseNullString(int sqlType) {
	String v = "null";

	switch ( sqlType ) {
		case Types.BIT:
		case Types.TINYINT:
		case Types.SMALLINT:
		case Types.INTEGER:
		case Types.BIGINT:
		case Types.FLOAT:
		case Types.REAL:
		case Types.DOUBLE:
		case Types.NUMERIC:
		case Types.DECIMAL:
			v = "cast(null as decimal)";
			break;
		case Types.CHAR:
		case Types.VARCHAR:
		case Types.LONGVARCHAR:
			v = "cast(null as varchar(255))";
			break;
		case Types.DATE:
		case Types.TIME:
		case Types.TIMESTAMP:
			v = "cast(null as timestamp)";
			break;
		case Types.BINARY:
		case Types.VARBINARY:
		case Types.LONGVARBINARY:
		case Types.NULL:
		case Types.OTHER:
		case Types.JAVA_OBJECT:
		case Types.DISTINCT:
		case Types.STRUCT:
		case Types.ARRAY:
		case Types.BLOB:
		case Types.CLOB:
		case Types.REF:
		case Types.DATALINK:
		case Types.BOOLEAN:
			break;
	}
	return v;
}
 
Example 19
Source File: TeradataDialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public String getSelectClauseNullString(int sqlType) {
	String v = "null";

	switch ( sqlType ) {
		case Types.BIT:
		case Types.TINYINT:
		case Types.SMALLINT:
		case Types.INTEGER:
		case Types.BIGINT:
		case Types.FLOAT:
		case Types.REAL:
		case Types.DOUBLE:
		case Types.NUMERIC:
		case Types.DECIMAL:
			v = "cast(null as decimal)";
			break;
		case Types.CHAR:
		case Types.VARCHAR:
		case Types.LONGVARCHAR:
			v = "cast(null as varchar(255))";
			break;
		case Types.DATE:
		case Types.TIME:
		case Types.TIMESTAMP:
			v = "cast(null as timestamp)";
			break;
		case Types.BINARY:
		case Types.VARBINARY:
		case Types.LONGVARBINARY:
		case Types.NULL:
		case Types.OTHER:
		case Types.JAVA_OBJECT:
		case Types.DISTINCT:
		case Types.STRUCT:
		case Types.ARRAY:
		case Types.BLOB:
		case Types.CLOB:
		case Types.REF:
		case Types.DATALINK:
		case Types.BOOLEAN:
			break;
	}
	return v;
}
 
Example 20
Source File: SQLTypeUtil.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Convert sql types to String for display
 *
 * @param sqlType the type number from java.sql.Types
 * @return the type name
 */
static public String getSqlTypeString(int sqlType) {
    switch (sqlType) {
        case Types.BIGINT:
            return "BIGINT"; //NOI18N
        case Types.BINARY:
            return "BINARY"; //NOI18N
        case Types.BIT:
            return "BIT"; //NOI18N
        case Types.NCHAR:
            return "NCHAR"; //NOI18N
        case Types.CHAR:
            return "CHAR"; //NOI18N
        case Types.DATE:
            return "DATE"; //NOI18N
        case Types.DECIMAL:
            return "DECIMAL"; //NOI18N
        case Types.DOUBLE:
            return "DOUBLE"; //NOI18N
        case Types.FLOAT:
            return "FLOAT"; //NOI18N
        case Types.INTEGER:
            return "INTEGER"; //NOI18N
        case Types.LONGVARBINARY:
            return "LONGVARBINARY"; //NOI18N
        case Types.LONGNVARCHAR:
            return "LONGNVARCHAR"; //NOI18N
        case Types.LONGVARCHAR:
            return "LONGVARCHAR"; //NOI18N
        case Types.NULL:
            return "NULL"; //NOI18N
        case Types.NUMERIC:
            return "NUMERIC"; //NOI18N
        case Types.OTHER:
            return "OTHER"; //NOI18N
        case Types.REAL:
            return "REAL"; //NOI18N
        case Types.SMALLINT:
            return "SMALLINT"; //NOI18N
        case Types.TIME:
            return "TIME"; //NOI18N
        case Types.TIMESTAMP:
            return "TIMESTAMP"; //NOI18N
        case Types.TINYINT:
            return "TINYINT"; //NOI18N
        case Types.VARBINARY:
            return "VARBINARY"; //NOI18N
        case Types.NVARCHAR:
            return "NVARCHAR";
        case Types.VARCHAR:
            return "VARCHAR"; //NOI18N
        case Types.JAVA_OBJECT:
            return "JAVA_OBJECT"; //NOI18N
        case Types.DISTINCT:
            return "DISTINCT"; //NOI18N
        case Types.STRUCT:
            return "STRUCT"; //NOI18N
        case Types.ARRAY:
            return "ARRAY"; //NOI18N
        case Types.BLOB:
            return "BLOB"; //NOI18N
        case Types.NCLOB:
            return "NCLOB";
        case Types.CLOB:
            return "CLOB"; //NOI18N
        case Types.REF:
            return "REF"; //NOI18N
        default:
            Logger.getLogger(SQLTypeUtil.class.getName()).log(Level.WARNING, "Unknown JDBC column type: {0}. Returns null.", sqlType);
            return "UNKNOWN"; //NOI18N
    }
}