Java Code Examples for java.sql.Types#BINARY

The following examples show how to use java.sql.Types#BINARY . 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: CloudSpannerResultSetMetaData.java    From spanner-jdbc with MIT License 6 votes vote down vote up
@Override
public int getColumnDisplaySize(int column) throws SQLException {
  int colType = getColumnType(column);
  switch (colType) {
    case Types.ARRAY:
      return 50;
    case Types.BOOLEAN:
      return 5;
    case Types.BINARY:
      return 50;
    case Types.DATE:
      return 10;
    case Types.DOUBLE:
      return 14;
    case Types.BIGINT:
      return 10;
    case Types.NVARCHAR:
      int length = getPrecision(column);
      return length == 0 ? 50 : length;
    case Types.TIMESTAMP:
      return 16;
    default:
      return 10;
  }
}
 
Example 2
Source File: RowSetMetaDataTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "columnClassNames")
private Object[][] columnClassNames() {
    return new Object[][]{
        {Types.CHAR, "java.lang.String"},
        {Types.NCHAR, "java.lang.String"},
        {Types.VARCHAR, "java.lang.String"},
        {Types.NVARCHAR, "java.lang.String"},
        {Types.LONGVARCHAR, "java.lang.String"},
        {Types.LONGNVARCHAR, "java.lang.String"},
        {Types.NUMERIC, "java.math.BigDecimal"},
        {Types.DECIMAL, "java.math.BigDecimal"},
        {Types.BIT, "java.lang.Boolean"},
        {Types.TINYINT, "java.lang.Byte"},
        {Types.SMALLINT, "java.lang.Short"},
        {Types.INTEGER, "java.lang.Integer"},
        {Types.FLOAT, "java.lang.Double"},
        {Types.DOUBLE, "java.lang.Double"},
        {Types.BINARY, "byte[]"},
        {Types.VARBINARY, "byte[]"},
        {Types.LONGVARBINARY, "byte[]"},
        {Types.DATE, "java.sql.Date"},
        {Types.TIME, "java.sql.Time"},
        {Types.TIMESTAMP, "java.sql.Timestamp"},
        {Types.CLOB, "java.sql.Clob"},
        {Types.BLOB, "java.sql.Blob"}

    };

}
 
Example 3
Source File: PostgreSqlPlatform.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void setObject(PreparedStatement statement, int sqlIndex, DynaBean dynaBean, SqlDynaProperty property) throws SQLException
{
    int     typeCode = property.getColumn().getTypeCode();
    Object  value    = dynaBean.get(property.getName());

    // PostgreSQL doesn't like setNull for BYTEA columns
    if (value == null)
    {
        switch (typeCode)
        {
            case Types.BINARY:
            case Types.VARBINARY:
            case Types.LONGVARBINARY:
            case Types.BLOB:
                statement.setBytes(sqlIndex, null);
                break;
            default:
                statement.setNull(sqlIndex, typeCode);
                break;
        }
    }
    else
    {
        super.setObject(statement, sqlIndex, dynaBean, property);
    }
}
 
Example 4
Source File: DVDStoreResultSet.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public InputStream getAsciiStream(int columnIndex) throws SQLException {
  if (columnIndex > 0 && columnIndex <= this.numColumns) {
    final TableMetaData metadata = getMetaData();
    final int colType = metadata.getColumnType(columnIndex);
    switch (colType) {
      case Types.CHAR:
      case Types.VARCHAR:
      case Types.LONGVARCHAR:
      case JDBC40Translation.JSON:
      case Types.CLOB: // Embedded and JCC extension
        break;

      // JDBC says to support these, we match JCC by returning the raw bytes.
      case Types.BINARY:
      case Types.VARBINARY:
      case Types.LONGVARBINARY:
      case Types.BLOB:
        return getBinaryStream(columnIndex);

      default:
        throw dataConversionException(
            metadata.getColumnTypeName(columnIndex), "InputStream(ASCII)",
            columnIndex);
    }

    final Reader reader = getCharacterStream(columnIndex);
    if (reader != null) {
      return new ReaderToAscii(reader);
    }
    else {
      return null;
    }
  }
  else {
    throw invalidColumnException(columnIndex);
  }
}
 
Example 5
Source File: DatabaseMetaDataProvider.java    From morf with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a given SQL data type to a {@link DataType}.
 *
 * @param typeCode JDBC data type.
 * @param typeName JDBC type name.
 * @param width JDBC column size.
 * @return Morf data type.
 */
protected DataType dataTypeFromSqlType(int typeCode, String typeName, int width) {
  switch (typeCode) {
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
      return DataType.INTEGER;
    case Types.BIGINT:
      return DataType.BIG_INTEGER;
    case Types.FLOAT:
    case Types.REAL:
    case Types.DOUBLE:
    case Types.NUMERIC:
    case Types.DECIMAL:
      return DataType.DECIMAL;
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    case Types.LONGNVARCHAR:
    case Types.NVARCHAR:
      return DataType.STRING;
    case Types.BOOLEAN:
    case Types.BIT:
      return DataType.BOOLEAN;
    case Types.DATE:
      return DataType.DATE;
    case Types.BLOB:
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
      return DataType.BLOB;
    case Types.NCLOB:
    case Types.CLOB:
      return DataType.CLOB;
    default:
      throw new UnexpectedDataTypeException("Unsupported data type [" + typeName + "] (type " + typeCode + " width " + width + ")");
  }
}
 
Example 6
Source File: RawStoreResultSet.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public InputStream getAsciiStream(int columnIndex) throws SQLException {
  if (columnIndex > 0 && columnIndex <= this.numColumns) {
    final TableMetaData metadata = getMetaData();
    final int colType = metadata.getColumnType(columnIndex);
    switch (colType) {
      case Types.CHAR:
      case Types.VARCHAR:
      case Types.LONGVARCHAR:
      case Types.CLOB: // Embedded and JCC extension
        break;

      // JDBC says to support these, we match JCC by returning the raw bytes.
      case Types.BINARY:
      case Types.VARBINARY:
      case Types.LONGVARBINARY:
      case Types.BLOB:
        return getBinaryStream(columnIndex);

      default:
        throw dataConversionException(
            metadata.getColumnTypeName(columnIndex), "InputStream(ASCII)",
            columnIndex);
    }

    final Reader reader = getCharacterStream(columnIndex);
    if (reader != null) {
      return new ReaderToAscii(reader);
    }
    else {
      return null;
    }
  }
  else {
    throw invalidColumnException(columnIndex);
  }
}
 
Example 7
Source File: SFResultSetMetaData.java    From snowflake-jdbc with Apache License 2.0 5 votes vote down vote up
private Integer calculatePrecision(SnowflakeColumnMetadata columnMetadata)
{
  int columnType = columnMetadata.getType();
  switch (columnType)
  {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.BINARY:
      return columnMetadata.getLength();
    case Types.INTEGER:
    case Types.DECIMAL:
    case Types.BIGINT:
      return columnMetadata.getPrecision();
    case Types.DATE:
      return dateStringLength;
    case Types.TIME:
      return timeStringLength;
    case SnowflakeUtil.EXTRA_TYPES_TIMESTAMP_LTZ:
      return timestampLTZStringLength;
    case SnowflakeUtil.EXTRA_TYPES_TIMESTAMP_TZ:
      return timestampTZStringLength;
    case Types.TIMESTAMP:
      return timestampNTZStringLength;
    // for double and boolean
    // Precision is not applicable hence return 0
    default:
      return 0;
  }
}
 
Example 8
Source File: Type1BlobResourcesConversionHandler.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public Object getSource(String id, ResultSet rs) throws SQLException
{
	ResultSetMetaData metadata = rs.getMetaData();
	String rv = null;
	switch(metadata.getColumnType(1))
	{
	case Types.BLOB:
		Blob blob = rs.getBlob(1);
		if(blob != null)
		{
			rv = new String(blob.getBytes(1L, (int) blob.length()));
		}
		break;
	case Types.CLOB:
		Clob clob = rs.getClob(1);
		if(clob != null)
		{
			rv = clob.getSubString(1L, (int) clob.length());
		}
		break;
	case Types.CHAR:
	case Types.LONGVARCHAR:
	case Types.VARCHAR:
	case Types.BINARY:
	case Types.VARBINARY:
	case Types.LONGVARBINARY:
		byte[] bytes = rs.getBytes(1);
		if(bytes != null)
		{
			rv = new String(bytes);
		}
		break;
	}
	return rv;
}
 
Example 9
Source File: JdbcTypeUtil.java    From canal with Apache License 2.0 5 votes vote down vote up
public static Class<?> jdbcType2javaType(int jdbcType) {
    switch (jdbcType) {
        case Types.BIT:
        case Types.BOOLEAN:
            // return Boolean.class;
        case Types.TINYINT:
            return Byte.TYPE;
        case Types.SMALLINT:
            return Short.class;
        case Types.INTEGER:
            return Integer.class;
        case Types.BIGINT:
            return Long.class;
        case Types.DECIMAL:
        case Types.NUMERIC:
            return BigDecimal.class;
        case Types.REAL:
            return Float.class;
        case Types.FLOAT:
        case Types.DOUBLE:
            return Double.class;
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGVARCHAR:
            return String.class;
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
        case Types.BLOB:
            return byte[].class;
        case Types.DATE:
            return Date.class;
        case Types.TIME:
            return Time.class;
        case Types.TIMESTAMP:
            return Timestamp.class;
        default:
            return String.class;
    }
}
 
Example 10
Source File: JdbcBroker.java    From geoportal-server-harvester with Apache License 2.0 4 votes vote down vote up
private JsonPropertyInjector createJsonPropertyInjectors(final String fieldName, final String columnName, final int columnType) {
  JsonPropertyInjector jsonPropertyInjector = null;
  
  switch (columnType) {
    case Types.VARCHAR:
    case Types.CHAR:
    case Types.LONGVARCHAR:
    case Types.LONGNVARCHAR:
    case Types.NVARCHAR:
    case Types.NCHAR:
      jsonPropertyInjector = (n, r)->n.put(fieldName, readValue(r, columnName, String.class));
      break;

    case Types.DOUBLE:
      jsonPropertyInjector = (n, r)->n.put(fieldName, safeToString(readValue(r, columnName, Double.class)));
      break;

    case Types.FLOAT:
      jsonPropertyInjector = (n, r)->n.put(fieldName, safeToString(readValue(r, columnName, Float.class)));
      break;

    case Types.INTEGER:
      jsonPropertyInjector = (n, r)->n.put(fieldName, safeToString(readValue(r, columnName, Integer.class)));
      break;

    case Types.SMALLINT:
    case Types.TINYINT:
      jsonPropertyInjector = (n, r)->n.put(fieldName, safeToString(readValue(r, columnName, Short.class)));
      break;

    case Types.BIGINT:
    case Types.DECIMAL:
    case Types.NUMERIC:
      jsonPropertyInjector = (n, r)->n.put(fieldName, safeToString(readValue(r, columnName, BigDecimal.class)));
      break;
  
    case Types.BOOLEAN:
      jsonPropertyInjector = (n, r)->n.put(fieldName, safeToString(readValue(r, columnName, Boolean.class)));
      break;

    case Types.DATE:
      jsonPropertyInjector = (n, r)->n.put(fieldName, formatIsoDate(r.getDate(columnName)));
      break;
    case Types.TIME:
      jsonPropertyInjector = (n, r)->n.put(fieldName, formatIsoDate(r.getTime(columnName)));
      break;
    case Types.TIMESTAMP:
      jsonPropertyInjector = (n, r)->n.put(fieldName, formatIsoDate(r.getTimestamp(columnName)));
      break;
      
    case Types.CLOB:
      jsonPropertyInjector = (n, r)->n.put(fieldName, formatClob(r.getClob(columnName)));
      break;
      
    case Types.BLOB:
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
      jsonPropertyInjector = (n, r)->n.put(fieldName, formatBlob(r.getBlob(columnName)));
      break;
  }
  
  return jsonPropertyInjector;
}
 
Example 11
Source File: PrestoResultSetMetaData.java    From presto with Apache License 2.0 4 votes vote down vote up
@Override
public String getColumnClassName(int column)
        throws SQLException
{
    // see javax.sql.rowset.RowSetMetaDataImpl
    switch (column(column).getColumnType()) {
        case Types.NUMERIC:
        case Types.DECIMAL:
            return BigDecimal.class.getName();
        case Types.BOOLEAN:
        case Types.BIT:
            return Boolean.class.getName();
        case Types.TINYINT:
            return Byte.class.getName();
        case Types.SMALLINT:
            return Short.class.getName();
        case Types.INTEGER:
            return Integer.class.getName();
        case Types.BIGINT:
            return Long.class.getName();
        case Types.REAL:
            return Float.class.getName();
        case Types.FLOAT:
        case Types.DOUBLE:
            return Double.class.getName();
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
            return "byte[]";
        case Types.DATE:
            return Date.class.getName();
        case Types.TIME:
            return Time.class.getName();
        case Types.TIMESTAMP:
            return Timestamp.class.getName();
        case Types.BLOB:
            return Blob.class.getName();
        case Types.CLOB:
            return Clob.class.getName();
        case Types.ARRAY:
            return Array.class.getName();
    }
    return String.class.getName();
}
 
Example 12
Source File: HiveColumnMetadataReaderTest.java    From virtual-schemas with MIT License 4 votes vote down vote up
@Test
void mapBinaryReturnVarchar() {
    final JdbcTypeDescription typeDescription = new JdbcTypeDescription(Types.BINARY, 0, 0, 0, "BINARY");
    assertThat(this.columnMetadataReader.mapJdbcType(typeDescription),
            equalTo(DataType.createMaximumSizeVarChar(DataType.ExaCharset.UTF8)));
}
 
Example 13
Source File: TableMetaParser.java    From tddl5 with Apache License 2.0 4 votes vote down vote up
public static String jdbcTypeToDataTypeString(int jdbcType, boolean isUnsigned) {
    String type = null;
    switch (jdbcType) {
        case Types.BIGINT:
            if (isUnsigned) {
                type = "BIGINTEGER";
            } else {
                type = "LONG";
            }
            break;
        case Types.NUMERIC:
        case Types.DECIMAL:
            type = "BIGDECIMAL";
            break;
        case Types.INTEGER:
            if (isUnsigned) {
                type = "LONG";
            } else {
                type = "INTEGER";
            }
            break;
        case Types.TINYINT:
        case Types.SMALLINT:
            type = "INTEGER";
            break;
        case Types.DATE:
            type = "DATE";
            break;
        case Types.TIMESTAMP:
            type = "TIMESTAMP";
            break;
        case Types.TIME:
            type = "TIME";
            break;
        case Types.REAL:
        case Types.FLOAT:
            type = "FLOAT";
            break;
        case Types.DOUBLE:
            type = "DOUBLE";
            break;
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.NCHAR:
        case Types.NVARCHAR:
        case Types.LONGNVARCHAR:
        case Types.LONGVARCHAR:
        case Types.CLOB:
            type = "STRING";
            break;
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
            type = "BYTES";
            break;
        case Types.BLOB:
            type = "BLOB";
            break;
        case Types.BIT:
            type = "BIT";
            break;
        default:
            throw new IllegalArgumentException("unsupport jdbcType :" + jdbcType);
    }

    return type;
}
 
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: DefaultAdaptor.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
/**
 * By default, we accord to Hive's type system for this converting.
 * @param sourceTypeId Column type id from Source
 * @return The column type name supported by Kylin.
 */
@Override
public String toKylinTypeName(int sourceTypeId) {
    String result = "any";

    switch (sourceTypeId) {
        case Types.CHAR:
            result = "char";
            break;
        case Types.VARCHAR:
        case Types.NVARCHAR:
        case Types.LONGVARCHAR:
            result = "varchar";
            break;
        case Types.NUMERIC:
        case Types.DECIMAL:
            result = "decimal";
            break;
        case Types.BIT:
        case Types.BOOLEAN:
            result = "boolean";
            break;
        case Types.TINYINT:
            result = "tinyint";
            break;
        case Types.SMALLINT:
            result = "smallint";
            break;
        case Types.INTEGER:
            result = "integer";
            break;
        case Types.BIGINT:
            result = "bigint";
            break;
        case Types.REAL:
        case Types.FLOAT:
        case Types.DOUBLE:
            result = "double";
            break;
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
            result = "byte";
            break;
        case Types.DATE:
            result = "date";
            break;
        case Types.TIME:
            result = "time";
            break;
        case Types.TIMESTAMP:
            result = "timestamp";
            break;
        default:
            //do nothing
            break;
    }

    return result;
}
 
Example 16
Source File: SqlUtil.java    From kylin with Apache License 2.0 4 votes vote down vote up
public static String jdbcTypeToKylinDataType(int sqlType) {
    String result = "any";

    switch (sqlType) {
    case Types.CHAR:
        result = "char";
        break;
    case Types.VARCHAR:
    case Types.NVARCHAR:
    case Types.LONGVARCHAR:
        result = "varchar";
        break;
    case Types.NUMERIC:
    case Types.DECIMAL:
        result = "decimal";
        break;
    case Types.BIT:
    case Types.BOOLEAN:
        result = "boolean";
        break;
    case Types.TINYINT:
        result = "tinyint";
        break;
    case Types.SMALLINT:
        result = "smallint";
        break;
    case Types.INTEGER:
        result = "integer";
        break;
    case Types.BIGINT:
        result = "bigint";
        break;
    case Types.REAL:
    case Types.FLOAT:
    case Types.DOUBLE:
        result = "double";
        break;
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        result = "byte";
        break;
    case Types.DATE:
        result = "date";
        break;
    case Types.TIME:
        result = "time";
        break;
    case Types.TIMESTAMP:
        result = "timestamp";
        break;
    default:
        //do nothing
        break;
    }

    return result;
}
 
Example 17
Source File: AbstractStringRowIterator.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Object getObject(int columnIndex) {
    int columnType = mycatRowMetaData.getColumnType(columnIndex);
    switch (columnType) {
        case Types.NUMERIC: {

        }
        case Types.DECIMAL: {
            return this.getBigDecimal(columnIndex);
        }
        case Types.BIT: {
            return this.getBoolean(columnIndex);
        }
        case Types.TINYINT: {
            return this.getByte(columnIndex);
        }
        case Types.SMALLINT: {
            return this.getShort(columnIndex);
        }
        case Types.INTEGER: {
            return this.getInt(columnIndex);
        }
        case Types.BIGINT: {
            return this.getLong(columnIndex);
        }
        case Types.REAL: {
            return this.getFloat(columnIndex);
        }
        case Types.FLOAT: {

        }
        case Types.DOUBLE: {
            return this.getDouble(columnIndex);
        }
        case Types.BINARY: {

        }
        case Types.VARBINARY: {

        }
        case Types.LONGVARBINARY: {
            return this.getBytes(columnIndex);
        }
        case Types.DATE: {
            return this.getDate(columnIndex);
        }
        case Types.TIME: {
            return this.getTime(columnIndex);
        }
        case Types.TIMESTAMP: {
            return this.getTimestamp(columnIndex);
        }
        case Types.CHAR: {

        }
        case Types.VARCHAR: {

        }
        case Types.LONGVARCHAR: {
            return this.getString(columnIndex);
        }
        case Types.BLOB: {

        }
        case Types.CLOB: {
            return this.getBytes(columnIndex);
        }
        case Types.NULL: {
            return null;
        }
        default:
            throw new RuntimeException("unsupport!");
    }
}
 
Example 18
Source File: SQLTypeMap.java    From Kylin with Apache License 2.0 4 votes vote down vote up
public static Object wrapObject(String value, int sqlType) {
    if (null == value) {
        return null;
    }

    switch (sqlType) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return value;
    case Types.NUMERIC:
    case Types.DECIMAL:
        return new BigDecimal(value);
    case Types.BIT:
        return Boolean.parseBoolean(value);
    case Types.TINYINT:
        return Byte.valueOf(value);
    case Types.SMALLINT:
        return Short.valueOf(value);
    case Types.INTEGER:
        return Integer.parseInt(value);
    case Types.BIGINT:
        return Long.parseLong(value);
    case Types.FLOAT:
        return Float.parseFloat(value);
    case Types.REAL:
    case Types.DOUBLE:
        return Double.parseDouble(value);
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        return value.getBytes();
    case Types.DATE:
        return Date.valueOf(value);
    case Types.TIME:
        return Time.valueOf(value);
    case Types.TIMESTAMP:
        return Timestamp.valueOf(value);
    }

    return value;
}
 
Example 19
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 20
Source File: Column.java    From paradoxdriver with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Gets if this field can be search.
 *
 * @return true if this field can be search.
 */
public boolean isSearchable() {
    return type != Types.BLOB && type != Types.BINARY;
}