Java Code Examples for java.sql.Types#REF

The following examples show how to use java.sql.Types#REF . 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: EmbedPreparedStatement.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Checks whether a data type is supported for
 * <code>setObject(int, Object, int)</code> and
 * <code>setObject(int, Object, int, int)</code>.
 *
 * @param dataType the data type to check
 * @exception SQLException if the type is not supported
 */
private void checkForSupportedDataType(int dataType) throws SQLException {

    // JDBC 4.0 javadoc for setObject() says:
    //
    // Throws: (...) SQLFeatureNotSupportedException - if
    // targetSqlType is a ARRAY, BLOB, CLOB, DATALINK,
    // JAVA_OBJECT, NCHAR, NCLOB, NVARCHAR, LONGNVARCHAR, REF,
    // ROWID, SQLXML or STRUCT data type and the JDBC driver does
    // not support this data type
    //
    // Of these types, we only support BLOB, CLOB and
    // (sort of) JAVA_OBJECT.

    switch (dataType) {
    case Types.ARRAY:
    case Types.DATALINK:
    case JDBC40Translation.NCHAR:
    case JDBC40Translation.NCLOB:
    case JDBC40Translation.NVARCHAR:
    case JDBC40Translation.LONGNVARCHAR:
    case Types.REF:
    case JDBC40Translation.ROWID:
    case JDBC40Translation.SQLXML:
    case Types.STRUCT:
        throw newSQLException(SQLState.DATA_TYPE_NOT_SUPPORTED,
                              Util.typeName(dataType));
    }
}
 
Example 2
Source File: DataViewUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static boolean isPrecisionRequired(int jdbcType) {
    switch (jdbcType) {
        case Types.BIGINT:
        case Types.BOOLEAN:
        case Types.INTEGER:
        case Types.SMALLINT:
        case Types.TINYINT:
        case Types.FLOAT:
        case Types.REAL:
        case Types.DOUBLE:
        case Types.DATE:
        case Types.TIMESTAMP:
        case Types.JAVA_OBJECT:
        case Types.LONGVARCHAR:
        case Types.LONGVARBINARY:
        case Types.BLOB:
        case Types.CLOB:
        case Types.ARRAY:
        case Types.STRUCT:
        case Types.DISTINCT:
        case Types.REF:
        case Types.DATALINK:
            return false;

        default:
            return true;
    }
}
 
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: JDBCTypeMapper.java    From Knowage-Server with GNU Affero General Public License v3.0 5 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 5
Source File: JdbcThinUtils.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param type a value from <code>java.sql.Types</code>.
 * @return {@code true} if type is plain and supported by thin JDBC driver.
 */
public static boolean isPlainJdbcType(int type) {
    return type != Types.ARRAY
        && type != Types.BLOB
        && type != Types.CLOB
        && type != Types.DATALINK
        && type != Types.JAVA_OBJECT
        && type != Types.NCHAR
        && type != Types.NVARCHAR
        && type != Types.LONGNVARCHAR
        && type != Types.REF
        && type != Types.ROWID
        && type != Types.SQLXML;
}
 
Example 6
Source File: WhereParser.java    From sql4es with Apache License 2.0 4 votes vote down vote up
/**
 * Parses predicats of types =, >, >=, <, <= and <>
 * @param compareExp
 * @param state
 * @return
 */
private QueryWrapper processComparison(ComparisonExpression compareExp, QueryState state) {
	String field = getVariableName(compareExp.getLeft());
	FieldAndType fat = getFieldAndType(field, state);
	field = fat.getFieldName();

	if(compareExp.getRight() instanceof Identifier || compareExp.getRight() instanceof DereferenceExpression){
		state.addException("Matching two columns is not supported : "+compareExp);
		return null;
	}
	// get value of the expression
	Object value = getLiteralValue(compareExp.getRight(), state);
	if(state.hasException()) return null;
	
	QueryBuilder comparison = null;
	String[] types = new String[state.getSources().size()];
	for(int i=0; i<types.length; i++) types[i] = state.getSources().get(i).getSource();
	if(compareExp.getType() == ComparisonExpressionType.EQUAL){
		if(field.equals(Heading.ID)) comparison = QueryBuilders.idsQuery(types).addIds((String)value);
		else if(field.equals(Heading.SEARCH)) comparison = QueryBuilders.queryStringQuery((String)value);
		else if(value instanceof String) comparison = queryForString(field, (String)value);
		else comparison = QueryBuilders.termQuery(field, value);
	}else if(compareExp.getType() == ComparisonExpressionType.GREATER_THAN_OR_EQUAL){
		comparison = QueryBuilders.rangeQuery(field).from(value);
	}else if(compareExp.getType() == ComparisonExpressionType.LESS_THAN_OR_EQUAL){
		comparison = QueryBuilders.rangeQuery(field).to(value);
	}else if(compareExp.getType() == ComparisonExpressionType.GREATER_THAN){
		comparison = QueryBuilders.rangeQuery(field).gt(value);
	}else if(compareExp.getType() == ComparisonExpressionType.LESS_THAN){
		comparison = QueryBuilders.rangeQuery(field).lt(value);
	}else if(compareExp.getType() == ComparisonExpressionType.NOT_EQUAL){
		if(field.equals(Heading.ID)){
			state.addException("Matching document _id using '<>' is not supported");
			return null;
		}
		comparison = QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery(field, value));
	};
	if(fat.getFieldType() == Types.REF) 
		return new QueryWrapper( comparison, field.split("\\.")[0]);
	return new QueryWrapper(comparison);
}
 
Example 7
Source File: Util.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static String typeName(int jdbcType) {
	switch (jdbcType) {
		case Types.ARRAY: return TypeId.ARRAY_NAME;
		case Types.BIT 		:  return TypeId.BIT_NAME;
		case Types.BOOLEAN  : return TypeId.BOOLEAN_NAME;
		case Types.DATALINK: return TypeId.DATALINK_NAME;
		case Types.TINYINT 	:  return TypeId.TINYINT_NAME;
		case Types.SMALLINT	:  return TypeId.SMALLINT_NAME;
		case Types.INTEGER 	:  return TypeId.INTEGER_NAME;
		case Types.BIGINT 	:  return TypeId.LONGINT_NAME;

		case Types.FLOAT 	:  return TypeId.FLOAT_NAME;
		case Types.REAL 	:  return TypeId.REAL_NAME;
		case Types.DOUBLE 	:  return TypeId.DOUBLE_NAME;

		case Types.NUMERIC 	:  return TypeId.NUMERIC_NAME;
		case Types.DECIMAL	:  return TypeId.DECIMAL_NAME;

		case Types.CHAR		:  return TypeId.CHAR_NAME;
		case Types.VARCHAR 	:  return TypeId.VARCHAR_NAME;
		case Types.LONGVARCHAR 	:  return "LONGVARCHAR";
           case Types.CLOB     :  return TypeId.CLOB_NAME;

		case Types.DATE 		:  return TypeId.DATE_NAME;
		case Types.TIME 		:  return TypeId.TIME_NAME;
		case Types.TIMESTAMP 	:  return TypeId.TIMESTAMP_NAME;

		case Types.BINARY			:  return TypeId.BINARY_NAME;
		case Types.VARBINARY	 	:  return TypeId.VARBINARY_NAME;
		case Types.LONGVARBINARY 	:  return TypeId.LONGVARBINARY_NAME;
           case Types.BLOB             :  return TypeId.BLOB_NAME;

		case Types.OTHER		:  return "OTHER";
		case Types.JAVA_OBJECT	:  return "Types.JAVA_OBJECT";
		case Types.REF : return TypeId.REF_NAME;
		case JDBC40Translation.ROWID: return TypeId.ROWID_NAME;
		case Types.STRUCT: return TypeId.STRUCT_NAME;
		case StoredFormatIds.XML_TYPE_ID :  return TypeId.XML_NAME;
		case JDBC40Translation.SQLXML: return TypeId.SQLXML_NAME;
		case JDBC40Translation.JSON: return TypeId.JSON_NAME;
		default : return String.valueOf(jdbcType);
	}
}
 
Example 8
Source File: AttributeSetup.java    From celerio with Apache License 2.0 4 votes vote down vote up
private MappedType getRawMappedType() {
    switch (attribute.getJdbcType().getJdbcType()) {
        case Types.ARRAY:
            return M_ARRAY;
        case Types.BIGINT:
            return M_LONG;
        case Types.BINARY:
            return M_BYTES;
        case Types.BIT:
        case Types.BOOLEAN:
            return M_BOOLEAN;
        case Types.BLOB:
            return M_BLOB;
        case Types.CLOB:
        case Types.NCLOB:
        case Types.SQLXML:
            return M_CLOB;
        case Types.DATALINK:
            return M_URL;
        case Types.DATE:
            return M_UTILDATE;
        case Types.DISTINCT:
        case Types.JAVA_OBJECT:
            return M_OBJECT;
        case Types.DOUBLE:
        case Types.FLOAT:
            return M_DOUBLE;
        case Types.INTEGER:
        case Types.SMALLINT:
        case Types.TINYINT:
            return M_INTEGER;
        case Types.LONGVARBINARY:
            return M_BYTES;
        case Types.CHAR:
        case Types.LONGVARCHAR:
        case Types.VARCHAR:
        case Types.LONGNVARCHAR:
        case Types.NCHAR:
        case Types.NVARCHAR:
            return M_STRING;
        case Types.DECIMAL:
        case Types.NUMERIC:
            ColumnConfig column = attribute.getColumnConfig();
            if (column.getDecimalDigits() > 0) {
                if (column.getSize() < 11 && column.getDecimalDigits() < 4) {
                    return M_DOUBLE;
                } else {
                    return M_BIGDECIMAL;
                }
            } else {
                if (column.getSize() == 1 && IS_BOOLEAN_PREFIX.apply(attribute)) {
                    return M_BOOLEAN;
                } else {
                    if (column.getSize() < 11) {
                        return M_INTEGER;
                    } else if (column.getSize() < 19 || attribute.isInPk() || attribute.isInFk()) { // BIG INTEGER IS NOT
                        // ACCEPTED BY HIBERNATE
                        // FOR PK
                        return M_LONG;
                    } else {
                        return M_BIGINTEGER;
                    }
                }
            }
        case Types.OTHER:
            return M_OBJECT;
        case Types.REAL:
            return M_FLOAT;
        case Types.REF:
            return M_REF;
        case Types.STRUCT:
            return M_OBJECT;
        case Types.TIME:
        case Types.TIMESTAMP:
            return M_UTILDATE;
        case Types.VARBINARY:
            if (attribute.getColumnConfig().getSize() == 1) {
                return M_BYTE;
            } else {
                return M_BYTES;
            }
        case Types.ROWID:
            return M_LONG;
        default:
            throw new RuntimeException("Could not retrieve the type of " + this);
    }
}
 
Example 9
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 10
Source File: JdbcTypeHelper.java    From SimpleFlatMapper with MIT License 4 votes vote down vote up
public static Class<?> toJavaType(int sqlType, Type propertyType) {
    switch (sqlType) {
        case Types.ARRAY: return Array.class;
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGNVARCHAR:
            return String.class;
        case Types.NUMERIC:
        case Types.DECIMAL:
            return BigDecimal.class;
        case Types.BIT:
            return boolean.class;
        case Types.TINYINT:
            return byte.class;
        case Types.SMALLINT:
            return short.class;
        case Types.INTEGER:
            return int.class;
        case Types.BIGINT:
            return long.class;
        case Types.REAL:
            return float.class;
        case Types.FLOAT:
        case Types.DOUBLE:
            return double.class;
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
            return byte[].class;
        case Types.DATE:
            return Date.class;
        case Types.TIME:
            return Time.class;
        case Types.TIMESTAMP:
            return Timestamp.class;
        case Types.CLOB:
            return Clob.class;
        case Types.BLOB:
            return Blob.class;
        case Types.STRUCT:
            return Struct.class;
        case Types.REF:
            return Ref.class;

        //IFJAVA8_START
        case Types.TIME_WITH_TIMEZONE:
            return OffsetTime.class;
        case Types.TIMESTAMP_WITH_TIMEZONE:
            return OffsetDateTime.class;
        //IFJAVA8_END

    }

    Class<?> defaultSqlType = javaTypeToSqlType.get(TypeHelper.toClass(propertyType).getName());
    if (defaultSqlType != null) {
        return defaultSqlType;
    }

    return Object.class;
}
 
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: 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 13
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 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: 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 16
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 17
Source File: ClientTypes.java    From vertx-sql-client with Apache License 2.0 4 votes vote down vote up
public static String getTypeString(int type) {
    switch (type) {
    case BIGINT:
        return "BIGINT";
    case BINARY:
        return "BINARY";
    case BLOB:
        return "BLOB";
    case BIT:
    case BOOLEAN:
        return "BOOLEAN";
    case CHAR:
        return "CHAR";
    case CLOB:
        return "CLOB";
    case DATE:
        return "DATE";
    case DECIMAL:
        return "DECIMAL";
    case DOUBLE:
        return "DOUBLE";
    case INTEGER:
        return "INTEGER";
    case LONGVARBINARY:
        return "LONGVARBINARY";
    case LONGVARCHAR:
        return "LONGVARCHAR";
    case REAL:
        return "REAL";
    case SMALLINT:
        return "SMALLINT";
    case TIME:
        return "TIME";
    case TIMESTAMP:
        return "TIMESTAMP";
    case VARBINARY:
        return "VARBINARY";
    case VARCHAR:
        return "VARCHAR";
    case ROWID:
        return "ROWID";
    // Types we don't support:
    case Types.ARRAY:
        return "ARRAY";
    case Types.DATALINK:
        return "DATALINK";
    case Types.REF:
        return "REF";
    case Types.SQLXML:
        return "SQLXML";
    case Types.STRUCT:
        return "STRUCT";
    // Unknown type:
    default:
        return "UNKNOWN(" + type + ")";
    }
}
 
Example 18
Source File: SQL92.java    From GeoTriples with Apache License 2.0 4 votes vote down vote up
public DataType getDataType(int jdbcType, String name, int size) {
	// TODO: These are in java.sql.Types as of Java 6 but not yet in Java 1.5
	if ("NCHAR".equals(name) || "NVARCHAR".equals(name) || "NCLOB".equals(name)) {
		return new SQLCharacterStringVarying(name, true);
	}

	
	switch (jdbcType) {
	case Types.CHAR:
		return new SQLCharacterString(name, true);

	case Types.VARCHAR:
	case Types.LONGVARCHAR:
	case Types.CLOB:
		return new SQLCharacterStringVarying(name, true);
		
	case Types.BOOLEAN:
		return new SQLBoolean(name);

	case Types.BINARY:
	case Types.VARBINARY:
	case Types.LONGVARBINARY:
	case Types.BLOB:
		return new SQLBinary(name, true);
		
	case Types.BIT:
		return new SQLBit(name);

	case Types.NUMERIC:
	case Types.DECIMAL:
	case Types.TINYINT:
	case Types.SMALLINT:
	case Types.INTEGER:
	case Types.BIGINT:
		return new SQLExactNumeric(name, jdbcType, false);
		
	case Types.REAL:
	case Types.FLOAT:
	case Types.DOUBLE:
		return new SQLApproximateNumeric(name);
	
	case Types.DATE:
		return new SQLDate(name);
		
	case Types.TIME:
		return new SQLTime(name);
		
	case Types.TIMESTAMP:
		return new SQLTimestamp(name);

	case Types.ARRAY:
	case Types.JAVA_OBJECT:
		return new UnsupportedDataType(jdbcType, name);
		
	// TODO: What about the remaining java.sql.Types?
	case Types.DATALINK:
	case Types.DISTINCT:
	case Types.NULL:
	case Types.OTHER:
	case Types.REF:
	}
	
	return null;
}
 
Example 19
Source File: TypeMapper.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static Class mapSQLType( final int t ) {
  switch ( t ) {
    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;
  }
}
 
Example 20
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 "?";
}