Java Code Examples for java.sql.Types#DATALINK

The following examples show how to use java.sql.Types#DATALINK . 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: PreparedStatement.java    From Komondor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see PreparedStatement#setURL(int, URL)
 */
public void setURL(int parameterIndex, URL arg) throws SQLException {
    if (arg != null) {
        setString(parameterIndex, arg.toString());

        this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.DATALINK;
    } else {
        setNull(parameterIndex, Types.CHAR);
    }
}
 
Example 2
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 3
Source File: SQLUtil.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Converts sql type into string.
 * @param sqlType
 * @return
 */
public static String sqlType2str(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";
    default: return "<unknown sql type>";
    }
    
}
 
Example 4
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 5
Source File: PreparedStatement.java    From r-course with MIT License 5 votes vote down vote up
/**
 * @see PreparedStatement#setURL(int, URL)
 */
public void setURL(int parameterIndex, URL arg) throws SQLException {
    if (arg != null) {
        setString(parameterIndex, arg.toString());

        this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.DATALINK;
    } else {
        setNull(parameterIndex, Types.CHAR);
    }
}
 
Example 6
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 7
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 8
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 9
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 10
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 11
Source File: AvaticaSite.java    From calcite-avatica with Apache License 2.0 4 votes vote down vote up
/** Similar logic to {@link #setObject}. */
public static Object get(Cursor.Accessor accessor, int targetSqlType,
    Calendar localCalendar) throws SQLException {
  switch (targetSqlType) {
  case Types.CLOB:
  case Types.DATALINK:
  case Types.NCLOB:
  case Types.REF:
  case Types.SQLXML:
    throw notImplemented();
  case Types.STRUCT:
    return accessor.getStruct();
  case Types.ARRAY:
    return accessor.getArray();
  case Types.BIGINT:
    final long aLong = accessor.getLong();
    if (aLong == 0 && accessor.wasNull()) {
      return null;
    }
    return aLong;
  case Types.BINARY:
  case Types.LONGVARBINARY:
  case Types.VARBINARY:
    return accessor.getBytes();
  case Types.BIT:
  case Types.BOOLEAN:
    final boolean aBoolean = accessor.getBoolean();
    if (!aBoolean && accessor.wasNull()) {
      return null;
    }
    return aBoolean;
  case Types.BLOB:
    return accessor.getBlob();
  case Types.DATE:
    return accessor.getDate(localCalendar);
  case Types.DECIMAL:
  case Types.NUMERIC:
    return accessor.getBigDecimal();
  case Types.DISTINCT:
    throw notImplemented();
  case Types.DOUBLE:
  case Types.FLOAT: // yes really; SQL FLOAT is up to 8 bytes
    final double aDouble = accessor.getDouble();
    if (aDouble == 0 && accessor.wasNull()) {
      return null;
    }
    return aDouble;
  case Types.INTEGER:
    final int anInt = accessor.getInt();
    if (anInt == 0 && accessor.wasNull()) {
      return null;
    }
    return anInt;
  case Types.JAVA_OBJECT:
  case Types.OTHER:
    return accessor.getObject();
  case Types.LONGNVARCHAR:
  case Types.LONGVARCHAR:
  case Types.NVARCHAR:
  case Types.VARCHAR:
  case Types.CHAR:
  case Types.NCHAR:
    return accessor.getString();
  case Types.REAL:
    final float aFloat = accessor.getFloat();
    if (aFloat == 0 && accessor.wasNull()) {
      return null;
    }
    return aFloat;
  case Types.ROWID:
    throw notImplemented();
  case Types.SMALLINT:
    final short aShort = accessor.getShort();
    if (aShort == 0 && accessor.wasNull()) {
      return null;
    }
    return aShort;
  case Types.TIME:
    return accessor.getTime(localCalendar);
  case Types.TIMESTAMP:
    return accessor.getTimestamp(localCalendar);
  case Types.TINYINT:
    final byte aByte = accessor.getByte();
    if (aByte == 0 && accessor.wasNull()) {
      return null;
    }
    return aByte;
  default:
    throw notImplemented();
  }
}
 
Example 12
Source File: DatabaseStatement.java    From sndml3 with MIT License 4 votes vote down vote up
private static String sqlTypeName(int sqltype) {
	switch (sqltype) {
		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.BOOLEAN:       return "BOOLEAN";
		case Types.CHAR:          return "CHAR";
		case Types.CLOB:          return "CLOB";
		case Types.DATALINK:      return "DATALINK";
		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.LONGNVARCHAR:  return "LONGNVARCHAR";
		case Types.LONGVARBINARY: return "LONGVARBINARY";
		case Types.LONGVARCHAR:   return "LONGVARCHAR";
		case Types.NCHAR:         return "NCHAR";
		case Types.NCLOB:         return "NCLOB";
		case Types.NULL:          return "NULL";
		case Types.NUMERIC:       return "NUMERIC";
		case Types.NVARCHAR:      return "NVARCHAR";
		case Types.OTHER:         return "OTHER";
		case Types.REAL:          return "REAL";
		case Types.REF:           return "REF";
		case Types.ROWID:         return "ROWID";
		case Types.SMALLINT:      return "SMALLINT";
		case Types.SQLXML:        return "SQLXML";
		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 Integer.toString(sqltype);
	}
}
 
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: 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 15
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 16
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 17
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 18
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 19
Source File: TypesTranslator.java    From sql-layer with GNU Affero General Public License v3.0 4 votes vote down vote up
public Class<?> jdbcClass(TInstance type) {
    TClass tclass = TInstance.tClass(type);
    if (tclass == null)
        return Object.class;
    int jdbcType = tclass.jdbcType();
    switch (jdbcType) {
    case Types.DECIMAL:
    case Types.NUMERIC:
        return BigDecimal.class;
    case Types.BOOLEAN:
        return Boolean.class;
    case Types.TINYINT:
        return Byte.class;
    case Types.BINARY:
    case Types.BIT:
    case Types.LONGVARBINARY:
    case Types.VARBINARY:
    case Types.BLOB:
        return byte[].class;
    case Types.DATE:
        return java.sql.Date.class;
    case Types.DOUBLE:
        return Double.class;
    case Types.FLOAT:
    case Types.REAL:
        return Float.class;
    case Types.INTEGER:
        return Integer.class;
    case Types.BIGINT:
        return Long.class;
    case Types.SMALLINT:
        return Short.class;
    case Types.CHAR:
    case Types.LONGNVARCHAR:
    case Types.LONGVARCHAR:
    case Types.NCHAR:
    case Types.NVARCHAR:
    case Types.VARCHAR:
    case Types.CLOB:
        return String.class;
    case Types.TIME:
        return java.sql.Time.class;
    case Types.TIMESTAMP:
        return java.sql.Timestamp.class;

    /*
    case Types.ARRAY:
        return java.sql.Array.class;
    case Types.BLOB:
        return java.sql.Blob.class;
    case Types.CLOB:
        return java.sql.Clob.class;
    case Types.NCLOB:
        return java.sql.NClob.class;
    case Types.REF:
        return java.sql.Ref.class;
    case Types.ROWID:
        return java.sql.RowId.class;
    case Types.SQLXML:
        return java.sql.SQLXML.class;
    */

    case Types.NULL:
    case Types.DATALINK:
    case Types.DISTINCT:
    case Types.JAVA_OBJECT:
    case Types.OTHER:
    case Types.STRUCT:
    default:
        break;
    }
    if (tclass == AkResultSet.INSTANCE)
        return java.sql.ResultSet.class;
    return Object.class;
}
 
Example 20
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;
  }
}