Java Code Examples for java.sql.Types#REAL
The following examples show how to use
java.sql.Types#REAL .
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: DataTypeDescriptor.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static boolean isNumericType(int jdbcType) { switch (jdbcType) { case Types.BIT: case Types.BOOLEAN: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: case Types.REAL: case Types.FLOAT: case Types.DOUBLE: case Types.DECIMAL: case Types.NUMERIC: return true; default: return false; } }
Example 2
Source File: DataTypeDescriptor.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
public static boolean isNumericType(int jdbcType){ switch(jdbcType){ case Types.BIT: case Types.BOOLEAN: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: case Types.REAL: case Types.FLOAT: case Types.DOUBLE: case Types.DECIMAL: case Types.NUMERIC: return true; default: return false; } }
Example 3
Source File: Cursor.java From vertx-sql-client with Apache License 2.0 | 5 votes |
public final int getInt(int column) throws SQLException { switch (jdbcTypes_[column - 1]) { case Types.BOOLEAN: return CrossConverters.getIntFromBoolean(get_BOOLEAN(column)); case Types.SMALLINT: return (int) get_SMALLINT(column); case Types.INTEGER: return get_INTEGER(column); case Types.BIGINT: return CrossConverters.getIntFromLong(get_BIGINT(column)); case Types.REAL: return CrossConverters.getIntFromFloat(get_FLOAT(column)); case Types.DOUBLE: return CrossConverters.getIntFromDouble(get_DOUBLE(column)); case Types.DECIMAL: // For performance we don't materialize the BigDecimal, but convert directly from decimal bytes to a long. return CrossConverters.getIntFromLong( getLongFromDECIMAL(column, "int")); case Types.CHAR: return CrossConverters.getIntFromString(get_CHAR(column)); case Types.VARCHAR: case Types.LONGVARCHAR: return CrossConverters.getIntFromString(get_VARCHAR(column)); default: throw coercionError( "int", column ); } }
Example 4
Source File: H2StorageManager.java From gsn with GNU General Public License v3.0 | 5 votes |
@Override public byte convertLocalTypeToGSN(int jdbcType, int precision) { switch (jdbcType) { case Types.BIGINT: return DataTypes.BIGINT; case Types.INTEGER: return DataTypes.INTEGER; case Types.SMALLINT: return DataTypes.SMALLINT; case Types.TINYINT: return DataTypes.TINYINT; case Types.VARCHAR: return DataTypes.VARCHAR; case Types.CHAR: return DataTypes.CHAR; case Types.DOUBLE: case Types.DECIMAL: // This is needed for doing aggregates in datadownload servlet. return DataTypes.DOUBLE; case Types.REAL: // Warning! The type FLOAT in H2 is a synonym of DOUBLE !! return DataTypes.FLOAT; case Types.BINARY: case Types.BLOB: case Types.VARBINARY: case Types.LONGVARBINARY: return DataTypes.BINARY; default: logger.error("The type can't be converted to GSN form : " + jdbcType); break; } return -100; }
Example 5
Source File: JdbcUtils.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Check whether the given SQL type is numeric. * @param sqlType the SQL type to be checked * @return whether the type is numeric */ public static boolean isNumeric(int sqlType) { return Types.BIT == sqlType || Types.BIGINT == sqlType || Types.DECIMAL == sqlType || Types.DOUBLE == sqlType || Types.FLOAT == sqlType || Types.INTEGER == sqlType || Types.NUMERIC == sqlType || Types.REAL == sqlType || Types.SMALLINT == sqlType || Types.TINYINT == sqlType; }
Example 6
Source File: DataViewUtils.java From netbeans with Apache License 2.0 | 5 votes |
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: GemFireXDManager.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * * @param sqlType * Type of the column as defined in GemFireXD table. * @param pxfType * Type of the column as defined in PXF external table. * @return True if columns' types match. False otherwise. */ public static boolean matchColumnTypes(int sqlType, int pxfType) { switch (DataType.get(pxfType)) { case SMALLINT: return sqlType == Types.SMALLINT; case INTEGER: return sqlType == Types.INTEGER; case BIGINT: return sqlType == Types.BIGINT; case REAL: return sqlType == Types.REAL; case FLOAT8: return sqlType == Types.DOUBLE; case VARCHAR: return sqlType == Types.VARCHAR; case BOOLEAN: return sqlType == Types.BOOLEAN; case NUMERIC: return sqlType == Types.NUMERIC; case TIMESTAMP: return sqlType == Types.TIMESTAMP; case BPCHAR: return sqlType == Types.VARCHAR || sqlType == Types.CHAR; case BYTEA: // http://www.public.iastate.edu/~java/docs/guide/jdbc/mapping.doc.html return sqlType == Types.BINARY || sqlType == Types.BLOB; case TEXT: return sqlType == Types.VARCHAR; case DATE: return sqlType == Types.DATE; case TIME: return sqlType == Types.TIME; default: break; } return false; }
Example 8
Source File: EventCallbackWriter.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Build the query string to insert a row to the backend database * * @param event * the callback event * @return SQL query string to insert a row to the back-end database * @throws SQLException */ private String buildInsertQuery(Event event) throws SQLException { ResultSetMetaData meta = event.getResultSetMetaData(); List<Object> newRow = event.getNewRow(); StringBuilder query = new StringBuilder(); // insert into table_name values (...); assume // Note: insert into table_name(col1, col2 ...) values (...) is not // supported here //query.append("INSERT INTO " + meta.getSchemaName(1) + "." // + meta.getTableName(1) + " VALUES ("); query.append("INSERT INTO " + meta.getSchemaName(1) + "." + meta.getTableName(1) + "_ONE VALUES ("); for (int i = 1; i <= meta.getColumnCount(); i++) { int type = meta.getColumnType(i); Object value = newRow.get(i - 1); switch (type) { case Types.BIGINT: case Types.DECIMAL: case Types.NUMERIC: case Types.SMALLINT: case Types.TINYINT: case Types.INTEGER: case Types.FLOAT: case Types.DOUBLE: case Types.REAL: case Types.TIMESTAMP: query.append(value + ","); break; default: query.append("'" + value + "',"); } } query.delete(query.length() - 1, query.length()); query.append(");"); return query.toString(); }
Example 9
Source File: GfxdCBArgForSynchPrms.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public String getColumnTypeName(int column) throws SQLException { if (column > 0 && column <= this.numParams) { if (this.dtds != null) { return this.dtds[column - 1].getTypeId().getSQLTypeName(); } else { switch (this.sqlParamTypes[column - 1]) { case Types.BOOLEAN: return TypeId.BOOLEAN_NAME; case Types.INTEGER: return TypeId.INTEGER_NAME; case Types.SMALLINT: return TypeId.SMALLINT_NAME; case Types.TINYINT: return TypeId.TINYINT_NAME; case Types.BIGINT: return TypeId.LONGINT_NAME; case Types.DECIMAL: return TypeId.DECIMAL_NAME; case Types.DOUBLE: return TypeId.DOUBLE_NAME; case Types.REAL: return TypeId.REAL_NAME; case Types.CHAR: return TypeId.CHAR_NAME; case Types.VARCHAR: return TypeId.VARCHAR_NAME; case Types.LONGVARCHAR: return TypeId.LONGVARCHAR_NAME; case CLOB: return TypeId.CLOB_NAME; case Types.BINARY: return TypeId.BIT_NAME; case Types.VARBINARY: return TypeId.VARBIT_NAME; case Types.LONGVARBINARY: return TypeId.LONGVARBIT_NAME; case BLOB: return TypeId.BLOB_NAME; case Types.DATE: return TypeId.DATE_NAME; case Types.TIME: return TypeId.TIME_NAME; case Types.TIMESTAMP: return TypeId.TIMESTAMP_NAME; case SQLXML: return TypeId.XML_NAME; case JSON: return TypeId.JSON_NAME; case JAVA_OBJECT: final DataValueDescriptor dvd = this.params[column - 1]; if (dvd != null) { try { final Object o = dvd.getObject(); if (o != null) { return o.getClass().getName(); } } catch (StandardException se) { throw Util.generateCsSQLException(se); } } return "NULL UDT"; default: throw Util.generateCsSQLException(SQLState.UNSUPPORTED_TYPE); } } } else { throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FOUND, Integer.valueOf(column)); } }
Example 10
Source File: MSSqlBuilder.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ protected String getValueAsString(Column column, Object value) { if (value == null) { return "NULL"; } StringBuilder result = new StringBuilder(); switch (column.getTypeCode()) { case Types.REAL: case Types.NUMERIC: case Types.FLOAT: case Types.DOUBLE: case Types.DECIMAL: // SQL Server does not want quotes around the value if (!(value instanceof String) && (getValueNumberFormat() != null)) { result.append(getValueNumberFormat().format(value)); } else { result.append(value.toString()); } break; case Types.DATE: result.append("CAST("); result.append(getPlatformInfo().getValueQuoteToken()); result.append(value instanceof String ? (String)value : getValueDateFormat().format(value)); result.append(getPlatformInfo().getValueQuoteToken()); result.append(" AS datetime)"); break; case Types.TIME: result.append("CAST("); result.append(getPlatformInfo().getValueQuoteToken()); result.append(value instanceof String ? (String)value : getValueTimeFormat().format(value)); result.append(getPlatformInfo().getValueQuoteToken()); result.append(" AS datetime)"); break; case Types.TIMESTAMP: result.append("CAST("); result.append(getPlatformInfo().getValueQuoteToken()); result.append(value.toString()); result.append(getPlatformInfo().getValueQuoteToken()); result.append(" AS datetime)"); break; } return super.getValueAsString(column, value); }
Example 11
Source File: StatementCreatorUtils.java From stategen with GNU Affero General Public License v3.0 | 4 votes |
public static Object getRandomValue(int sqlType,Integer scale) { switch(sqlType) { case Types.BIT:; case Types.TINYINT:; case Types.SMALLINT:; return (byte)randomNumber(); case Types.INTEGER:; case Types.BIGINT:; case Types.FLOAT:; case Types.REAL:; case Types.DOUBLE:; case Types.NUMERIC:; case Types.DECIMAL:; return (int)randomNumber(); case Types.DATE: case Types.TIME: case Types.TIMESTAMP: return now(); case Types.VARCHAR: case Types.CHAR: return randomString(scale); case Types.LONGVARCHAR: case Types.CLOB: return null; case -9 : //Types.NVARCHAR case -15: //Types.NCHAR case 2011: //Types.NCLOB return null; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: return null; case Types.NULL: case Types.OTHER: case Types.BLOB: return null; case Types.BOOLEAN: return false; case -10: //CURSOR case Integer.MIN_VALUE + 1000: //UNDEFINED return null; default: return null; } }
Example 12
Source File: StandardAnsiSqlAggregationFunctions.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public Type getReturnType(Type firstArgumentType, Mapping mapping) { final int jdbcType = determineJdbcTypeCode( firstArgumentType, mapping ); // First allow the actual type to control the return value; the underlying sqltype could // actually be different if ( firstArgumentType == StandardBasicTypes.BIG_INTEGER ) { return StandardBasicTypes.BIG_INTEGER; } else if ( firstArgumentType == StandardBasicTypes.BIG_DECIMAL ) { return StandardBasicTypes.BIG_DECIMAL; } else if ( firstArgumentType == StandardBasicTypes.LONG || firstArgumentType == StandardBasicTypes.SHORT || firstArgumentType == StandardBasicTypes.INTEGER ) { return StandardBasicTypes.LONG; } else if ( firstArgumentType == StandardBasicTypes.FLOAT || firstArgumentType == StandardBasicTypes.DOUBLE) { return StandardBasicTypes.DOUBLE; } // finally use the jdbcType if == on Hibernate types did not find a match. // // IMPL NOTE : we do not match on Types.NUMERIC because it could be either, so we fall-through to the // first argument type if ( jdbcType == Types.FLOAT || jdbcType == Types.DOUBLE || jdbcType == Types.DECIMAL || jdbcType == Types.REAL) { return StandardBasicTypes.DOUBLE; } else if ( jdbcType == Types.BIGINT || jdbcType == Types.INTEGER || jdbcType == Types.SMALLINT || jdbcType == Types.TINYINT ) { return StandardBasicTypes.LONG; } // as a last resort, return the type of the first argument return firstArgumentType; }
Example 13
Source File: AbstractHive3QLProcessor.java From nifi with Apache License 2.0 | 4 votes |
/** * Determines how to map the given value to the appropriate JDBC data jdbcType and sets the parameter on the * provided PreparedStatement * * @param stmt the PreparedStatement to set the parameter on * @param attrName the name of the attribute that the parameter is coming from - for logging purposes * @param parameterIndex the index of the HiveQL parameter to set * @param parameterValue the value of the HiveQL parameter to set * @param jdbcType the JDBC Type of the HiveQL parameter to set * @throws SQLException if the PreparedStatement throws a SQLException when calling the appropriate setter */ protected void setParameter(final PreparedStatement stmt, final String attrName, final int parameterIndex, final String parameterValue, final int jdbcType) throws SQLException { if (parameterValue == null) { stmt.setNull(parameterIndex, jdbcType); } else { try { switch (jdbcType) { case Types.BIT: case Types.BOOLEAN: stmt.setBoolean(parameterIndex, Boolean.parseBoolean(parameterValue)); break; case Types.TINYINT: stmt.setByte(parameterIndex, Byte.parseByte(parameterValue)); break; case Types.SMALLINT: stmt.setShort(parameterIndex, Short.parseShort(parameterValue)); break; case Types.INTEGER: stmt.setInt(parameterIndex, Integer.parseInt(parameterValue)); break; case Types.BIGINT: stmt.setLong(parameterIndex, Long.parseLong(parameterValue)); break; case Types.REAL: stmt.setFloat(parameterIndex, Float.parseFloat(parameterValue)); break; case Types.FLOAT: case Types.DOUBLE: stmt.setDouble(parameterIndex, Double.parseDouble(parameterValue)); break; case Types.DECIMAL: case Types.NUMERIC: stmt.setBigDecimal(parameterIndex, new BigDecimal(parameterValue)); break; case Types.DATE: stmt.setDate(parameterIndex, new Date(Long.parseLong(parameterValue))); break; case Types.TIME: stmt.setTime(parameterIndex, new Time(Long.parseLong(parameterValue))); break; case Types.TIMESTAMP: stmt.setTimestamp(parameterIndex, new Timestamp(Long.parseLong(parameterValue))); break; case Types.CHAR: case Types.VARCHAR: case Types.LONGNVARCHAR: case Types.LONGVARCHAR: stmt.setString(parameterIndex, parameterValue); break; default: stmt.setObject(parameterIndex, parameterValue, jdbcType); break; } } catch (SQLException e) { // Log which attribute/parameter had an error, then rethrow to be handled at the top level getLogger().error("Error setting parameter {} to value from {} ({})", new Object[]{parameterIndex, attrName, parameterValue}, e); throw e; } } }
Example 14
Source File: EventCallbackListener.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Build the query string to insert a row to the backend database * * @param event * the callback event * @return SQL query string to insert a row to the back-end database * @throws SQLException */ private String buildInsertQuery(Event event) throws SQLException { ResultSetMetaData meta = event.getResultSetMetaData(); List<Object> newRow = event.getNewRow(); StringBuilder query = new StringBuilder(); // insert into table_name values (...); assume // Note: insert into table_name(col1, col2 ...) values (...) is not // supported here //query.append("INSERT INTO " + meta.getSchemaName(1) + "." // + meta.getTableName(1) + " VALUES ("); query.append("INSERT INTO " + meta.getSchemaName(1) + "." + meta.getTableName(1) + "_ONE VALUES ("); for (int i = 1; i <= meta.getColumnCount(); i++) { int type = meta.getColumnType(i); Object value = newRow.get(i - 1); switch (type) { case Types.BIGINT: case Types.DECIMAL: case Types.NUMERIC: case Types.SMALLINT: case Types.TINYINT: case Types.INTEGER: case Types.FLOAT: case Types.DOUBLE: case Types.REAL: case Types.TIMESTAMP: query.append(value + ","); break; default: query.append("'" + value + "',"); } } query.delete(query.length() - 1, query.length()); query.append(");"); return query.toString(); }
Example 15
Source File: SQL92.java From GeoTriples with Apache License 2.0 | 4 votes |
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 16
Source File: JDBCTypeMapper.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
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 17
Source File: GfxdCBArgForSynchPrms.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
static final DataValueDescriptor getNullDVD(int sqlType) { switch (sqlType) { case Types.BINARY: return new SQLBit(); case Types.BIT: case Types.BOOLEAN: return new SQLBoolean(); case Types.CHAR: return new SQLChar(); case Types.DATE: return new SQLDate(); case Types.DOUBLE: return new SQLDouble(); case Types.INTEGER: return new SQLInteger(); case Types.BIGINT: return new SQLLongint(); case Types.DECIMAL: case Types.NUMERIC: return new SQLDecimal(); case Types.FLOAT: case Types.REAL: return new SQLReal(); case Types.SMALLINT: return new SQLSmallint(); case Types.TIME: return new SQLTime(); case Types.TIMESTAMP: return new SQLTimestamp(); case Types.TINYINT: return new SQLTinyint(); case Types.VARCHAR: return new SQLVarchar(); case Types.LONGVARCHAR: return new SQLLongvarchar(); case Types.VARBINARY: return new SQLVarbit(); case Types.LONGVARBINARY: return new SQLLongVarbit(); case Types.REF: return new SQLRef(); case BLOB: final SQLBlob blob = new SQLBlob(); blob.setWrapBytesForSQLBlob(true); return blob; case CLOB: return new SQLClob(); case JAVA_OBJECT: return new UserType(); case SQLXML: return new XML(); case JSON: return new JSON(); default: throw GemFireXDRuntimeException.newRuntimeException( "unexpected SQL type=" + sqlType, null); } }
Example 18
Source File: TableContextUtil.java From datacollector with Apache License 2.0 | 4 votes |
public static String generateNextPartitionOffset( TableContext tableContext, String column, String offset ) { final String partitionSize = tableContext.getOffsetColumnToPartitionOffsetAdjustments().get(column); final int offsetColumnType = tableContext.getOffsetColumnToType().get(column); switch (tableContext.getVendor()) { case ORACLE: if(TableContextUtil.VENDOR_PARTITIONABLE_TYPES.get(DatabaseVendor.ORACLE).contains(offsetColumnType)) { switch (offsetColumnType) { case TableContextUtil.TYPE_ORACLE_TIMESTAMP_WITH_LOCAL_TIME_ZONE: case TableContextUtil.TYPE_ORACLE_TIMESTAMP_WITH_TIME_ZONE: return ZonedDateTime.parse(offset, DateTimeFormatter.ISO_OFFSET_DATE_TIME) .plusSeconds(Integer.parseInt(partitionSize)) .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); default: throw new IllegalStateException(Utils.format("Unsupported type: {}", offsetColumnType)); } } break; case SQL_SERVER: if(TableContextUtil.VENDOR_PARTITIONABLE_TYPES.get(DatabaseVendor.SQL_SERVER).contains(offsetColumnType)) { if (offsetColumnType == TableContextUtil.TYPE_SQL_SERVER_DATETIMEOFFSET) { return ZonedDateTime.parse(offset, DateTimeFormatter.ISO_OFFSET_DATE_TIME) .plusSeconds(Integer.parseInt(partitionSize)) .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); } } break; } switch (offsetColumnType) { case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: final int int1 = Integer.parseInt(offset); final int int2 = Integer.parseInt(partitionSize); return String.valueOf(int1 + int2); case Types.TIMESTAMP: final Timestamp timestamp1 = getTimestampForOffsetValue(offset); final long timestampAdj = Long.parseLong(partitionSize); final Timestamp timestamp2 = Timestamp.from(timestamp1.toInstant().plusMillis(timestampAdj)); return getOffsetValueForTimestamp(timestamp2); case Types.BIGINT: // TIME, DATE are represented as long (epoch) case Types.TIME: case Types.DATE: final long long1 = Long.parseLong(offset); final long long2 = Long.parseLong(partitionSize); return String.valueOf(long1 + long2); case Types.FLOAT: case Types.REAL: final float float1 = Float.parseFloat(offset); final float float2 = Float.parseFloat(partitionSize); return String.valueOf(float1 + float2); case Types.DOUBLE: final double double1 = Double.parseDouble(offset); final double double2 = Double.parseDouble(partitionSize); return String.valueOf(double1 + double2); case Types.NUMERIC: case Types.DECIMAL: final BigDecimal decimal1 = new BigDecimal(offset); final BigDecimal decimal2 = new BigDecimal(partitionSize); return decimal1.add(decimal2).toString(); } return null; }
Example 19
Source File: SQLTypeMap.java From Kylin with Apache License 2.0 | 4 votes |
@SuppressWarnings("rawtypes") public static Class convert(int sqlType) { Class result = Object.class; switch (sqlType) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: result = String.class; break; case Types.NUMERIC: case Types.DECIMAL: result = BigDecimal.class; break; case Types.BIT: result = Boolean.class; break; case Types.TINYINT: result = Byte.class; break; case Types.SMALLINT: result = Short.class; break; case Types.INTEGER: result = Integer.class; break; case Types.BIGINT: result = Long.class; break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: result = Double.class; break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: result = Byte[].class; break; case Types.DATE: result = Date.class; break; case Types.TIME: result = Time.class; break; case Types.TIMESTAMP: result = Timestamp.class; break; } return result; }
Example 20
Source File: JDBCTypeMapper.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
public static Class getJavaType(short jdbcType) { switch (jdbcType) { case Types.ARRAY: return java.sql.Array.class; case Types.BIGINT: return java.lang.Long.class; case Types.BINARY: return java.lang.Byte[].class; case Types.BIT: return java.lang.Boolean.class; case Types.BLOB: return java.sql.Blob.class; case Types.CHAR: return java.lang.String.class; case Types.CLOB: return java.sql.Clob.class; case Types.DATE: return java.sql.Date.class; case Types.DECIMAL: return java.math.BigDecimal.class; case Types.DISTINCT: return java.lang.Object.class; case Types.DOUBLE: return java.lang.Double.class; case Types.FLOAT: return java.lang.Double.class; case Types.INTEGER: return java.lang.Integer.class; case Types.JAVA_OBJECT: return java.lang.Object.class; case Types.LONGVARBINARY: return java.lang.Byte[].class; case Types.LONGVARCHAR: return java.lang.String.class; case Types.NULL: return java.lang.Object.class; case Types.NUMERIC: return java.math.BigDecimal.class; case Types.OTHER: return java.lang.Object.class; case Types.REAL: return java.lang.Float.class; case Types.REF: return java.sql.Ref.class; case Types.SMALLINT: return java.lang.Short.class; case Types.STRUCT: return java.sql.Struct.class; case Types.TIME: return java.sql.Time.class; case Types.TIMESTAMP: return java.sql.Timestamp.class; case Types.TINYINT: return java.lang.Byte.class; case Types.VARBINARY: return java.lang.Byte[].class; case Types.VARCHAR: return java.lang.String.class; case Types.NVARCHAR: return java.lang.String.class; default: return null; } }