Java Code Examples for java.sql.Types#TIMESTAMP_WITH_TIMEZONE
The following examples show how to use
java.sql.Types#TIMESTAMP_WITH_TIMEZONE .
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: DbTrackingModule.java From OpenAs2App with BSD 2-Clause "Simplified" License | 5 votes |
private String formatField(String value, int dataType) { if (value == null) { return "NULL"; } switch (dataType) { case Types.BIGINT: case Types.DECIMAL: case Types.DOUBLE: case Types.FLOAT: case Types.INTEGER: case Types.NUMERIC: case Types.REAL: case Types.SMALLINT: case Types.BINARY: case Types.TINYINT: //case Types.ROWID: return value; case Types.TIME_WITH_TIMEZONE: case Types.TIMESTAMP_WITH_TIMEZONE: case Types.DATE: case Types.TIME: case Types.TIMESTAMP: if ("oracle".equalsIgnoreCase(dbPlatform)) { if (value.length() > 19) { return ("TO_TIMESTAMP('" + value + "','YYYY-MM-DD HH24:MI:SS.FF')"); } else { return ("TO_DATE('" + value + "','YYYY-MM-DD HH24:MI:SS')"); } } else if ("mssql".equalsIgnoreCase(dbPlatform)) { return ("CAST('" + value + "' AS DATETIME)"); } else { return "'" + value + "'"; } } // Must be some kind of string value if it gets here return "'" + value.replaceAll("'", sqlEscapeChar + "'") + "'"; }
Example 2
Source File: SpatialFunctions.java From sis with Apache License 2.0 | 5 votes |
/** * Maps a given SQL type to a Java class. * This method shall not return primitive types; their wrappers shall be used instead. * It may return array of primitive types however. * If no match is found, then this method returns {@code null}. * * <p>The default implementation handles the types declared in {@link Types} class. * Subclasses should handle the geometry types declared by spatial extensions.</p> * * @param sqlType SQL type code as one of {@link java.sql.Types} constants. * @param sqlTypeName data source dependent type name. For User Defined Type (UDT) the name is fully qualified. * @return corresponding java type, or {@code null} if unknown. */ @SuppressWarnings("fallthrough") protected Class<?> toJavaType(final int sqlType, final String sqlTypeName) { switch (sqlType) { case Types.BIT: case Types.BOOLEAN: return Boolean.class; case Types.TINYINT: if (!isByteUnsigned) return Byte.class; // else fallthrough. case Types.SMALLINT: return Short.class; case Types.INTEGER: return Integer.class; case Types.BIGINT: return Long.class; case Types.REAL: return Float.class; case Types.FLOAT: // Despite the name, this is implemented as DOUBLE in major databases. case Types.DOUBLE: return Double.class; case Types.NUMERIC: // Similar to DECIMAL except that it uses exactly the specified precision. case Types.DECIMAL: return BigDecimal.class; case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: return String.class; case Types.DATE: return LocalDate.class; case Types.TIME: return LocalTime.class; case Types.TIMESTAMP: return LocalDateTime.class; case Types.TIME_WITH_TIMEZONE: return OffsetTime.class; case Types.TIMESTAMP_WITH_TIMEZONE: return OffsetDateTime.class; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: return byte[].class; case Types.ARRAY: return Object[].class; case Types.OTHER: // Database-specific accessed via getObject and setObject. case Types.JAVA_OBJECT: return Object.class; default: return null; } }
Example 3
Source File: SqlParameterSourceBuilder.java From SimpleFlatMapper with MIT License | 5 votes |
private static int getParameterType(PropertyMapping<?, ?, JdbcColumnKey> pm) { Class<?> propertyType = TypeHelper.toClass(pm.getPropertyMeta().getPropertyType()); if (pm.getColumnDefinition().has(SqlTypeColumnProperty.class)) { return pm.getColumnDefinition().lookFor(SqlTypeColumnProperty.class).getSqlType(); } int t = StatementCreatorUtils.javaTypeToSqlParameterType(propertyType); if (t == SqlTypeValue.TYPE_UNKNOWN) { //IFJAVA8_START if (propertyType.equals(ZonedDateTime.class) || propertyType.equals(OffsetDateTime.class)) { return Types.TIMESTAMP_WITH_TIMEZONE; } if (propertyType.equals(Instant.class) || propertyType.equals(LocalDateTime.class)) { return Types.TIMESTAMP; } if (propertyType.equals(LocalDate.class)) { return Types.DATE; } if (propertyType.equals(LocalTime.class)) { return Types.TIME; } //IFJAVA8_END return JdbcColumnKey.UNDEFINED_TYPE; } return t; }
Example 4
Source File: FBTimestampTzFieldTest.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
@Before @Override public void setUp() throws Exception { super.setUp(); rowDescriptorBuilder.setType(ISCConstants.SQL_TIMESTAMP_TZ); fieldDescriptor = rowDescriptorBuilder.toFieldDescriptor(); field = new FBTimestampTzField(fieldDescriptor, fieldData, Types.TIMESTAMP_WITH_TIMEZONE); }
Example 5
Source File: JdbcMetadataHandlerTest.java From aws-athena-query-federation with Apache License 2.0 | 5 votes |
@Test public void doGetTable() throws SQLException { String[] schema = {"DATA_TYPE", "COLUMN_SIZE", "COLUMN_NAME", "DECIMAL_DIGITS", "NUM_PREC_RADIX"}; Object[][] values = {{Types.INTEGER, 12, "testCol1", 0, 0}, {Types.VARCHAR, 25, "testCol2", 0, 0}, {Types.TIMESTAMP, 93, "testCol3", 0, 0}, {Types.TIMESTAMP_WITH_TIMEZONE, 93, "testCol4", 0, 0}}; AtomicInteger rowNumber = new AtomicInteger(-1); ResultSet resultSet = mockResultSet(schema, values, rowNumber); SchemaBuilder expectedSchemaBuilder = SchemaBuilder.newBuilder(); expectedSchemaBuilder.addField(FieldBuilder.newBuilder("testCol1", org.apache.arrow.vector.types.Types.MinorType.INT.getType()).build()); expectedSchemaBuilder.addField(FieldBuilder.newBuilder("testCol2", org.apache.arrow.vector.types.Types.MinorType.VARCHAR.getType()).build()); PARTITION_SCHEMA.getFields().forEach(expectedSchemaBuilder::addField); Schema expected = expectedSchemaBuilder.build(); TableName inputTableName = new TableName("testSchema", "testTable"); Mockito.when(connection.getMetaData().getColumns("testCatalog", inputTableName.getSchemaName(), inputTableName.getTableName(), null)).thenReturn(resultSet); Mockito.when(connection.getCatalog()).thenReturn("testCatalog"); GetTableResponse getTableResponse = this.jdbcMetadataHandler.doGetTable( this.blockAllocator, new GetTableRequest(this.federatedIdentity, "testQueryId", "testCatalog", inputTableName)); Assert.assertEquals(expected, getTableResponse.getSchema()); Assert.assertEquals(inputTableName, getTableResponse.getTableName()); Assert.assertEquals("testCatalog", getTableResponse.getCatalogName()); }
Example 6
Source File: DBTablePrinter.java From salesforce-jdbc with MIT License | 5 votes |
/** * Takes a generic SQL type and returns the category this type * belongs to. Types are categorized according to print formatting * needs: * <p> * Integers should not be truncated so column widths should * be adjusted without a column width limit. Text columns should be * left justified and can be truncated to a max. column width etc...</p> * <p> * See also: <a target="_blank" * href="http://docs.oracle.com/javase/8/docs/api/java/sql/Types.html"> * java.sql.Types</a> * * @param type Generic SQL type * @return The category this type belongs to */ private static int whichCategory(int type) { switch (type) { case Types.BIGINT: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: return CATEGORY_INTEGER; case Types.REAL: case Types.DOUBLE: case Types.DECIMAL: return CATEGORY_DOUBLE; case Types.DATE: case Types.TIME: case Types.TIME_WITH_TIMEZONE: case Types.TIMESTAMP: case Types.TIMESTAMP_WITH_TIMEZONE: return CATEGORY_DATETIME; case Types.BOOLEAN: return CATEGORY_BOOLEAN; case Types.VARCHAR: case Types.NVARCHAR: case Types.LONGVARCHAR: case Types.LONGNVARCHAR: case Types.CHAR: case Types.NCHAR: return CATEGORY_STRING; default: return CATEGORY_OTHER; } }
Example 7
Source File: DBTablePrinter.java From salesforce-jdbc with MIT License | 5 votes |
/** * Takes a generic SQL type and returns the category this type * belongs to. Types are categorized according to print formatting * needs: * <p> * Integers should not be truncated so column widths should * be adjusted without a column width limit. Text columns should be * left justified and can be truncated to a max. column width etc...</p> * <p> * See also: <a target="_blank" * href="http://docs.oracle.com/javase/8/docs/api/java/sql/Types.html"> * java.sql.Types</a> * * @param type Generic SQL type * @return The category this type belongs to */ private static int whichCategory(int type) { switch (type) { case Types.BIGINT: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: return CATEGORY_INTEGER; case Types.REAL: case Types.DOUBLE: case Types.DECIMAL: return CATEGORY_DOUBLE; case Types.DATE: case Types.TIME: case Types.TIME_WITH_TIMEZONE: case Types.TIMESTAMP: case Types.TIMESTAMP_WITH_TIMEZONE: return CATEGORY_DATETIME; case Types.BOOLEAN: return CATEGORY_BOOLEAN; case Types.VARCHAR: case Types.NVARCHAR: case Types.LONGVARCHAR: case Types.LONGNVARCHAR: case Types.CHAR: case Types.NCHAR: return CATEGORY_STRING; default: return CATEGORY_OTHER; } }
Example 8
Source File: StorageRepository.java From fish-admin with MIT License | 4 votes |
@Override public int[] columnTypes() { return new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP_WITH_TIMEZONE }; }
Example 9
Source File: JdbcQuery.java From opentest with MIT License | 4 votes |
@Override public void run() { String jdbcUrl = this.readStringArgument("jdbcUrl"); String user = this.readStringArgument("user", null); String password = this.readStringArgument("password", null); String sql = this.readStringArgument("sql"); try { Connection conn; if (user != null && password != null) { conn = DriverManager.getConnection(jdbcUrl, user, password); } else { conn = DriverManager.getConnection(jdbcUrl); } Statement statement = conn.createStatement(); ResultSet resultSet = statement.executeQuery(sql); ResultSetMetaData rsMetaData = resultSet.getMetaData(); List<Map<String, Object>> rows = new ArrayList<>(); int columnCount = rsMetaData.getColumnCount(); while (resultSet.next()) { Map<String, Object> row = new HashMap<>(); for (int columnNo = 1; columnNo <= columnCount; columnNo++) { switch (rsMetaData.getColumnType(columnNo)) { case Types.DATE: case Types.TIME: case Types.TIME_WITH_TIMEZONE: case Types.TIMESTAMP: case Types.TIMESTAMP_WITH_TIMEZONE: row.put(rsMetaData.getColumnName(columnNo), resultSet.getObject(columnNo).toString()); break; default: row.put(rsMetaData.getColumnName(columnNo), resultSet.getObject(columnNo)); } } rows.add(row); } resultSet.close(); this.writeOutput("rows", rows); this.writeOutput("rowCount", rows.size()); } catch (SQLException ex) { throw new RuntimeException(ex); } }
Example 10
Source File: JDBC42Helper.java From r-course with MIT License | 4 votes |
static boolean isSqlTypeSupported(int sqlType) { return sqlType != Types.REF_CURSOR && sqlType != Types.TIME_WITH_TIMEZONE && sqlType != Types.TIMESTAMP_WITH_TIMEZONE; }
Example 11
Source File: JDBC42Helper.java From Komondor with GNU General Public License v3.0 | 4 votes |
static boolean isSqlTypeSupported(int sqlType) { return sqlType != Types.REF_CURSOR && sqlType != Types.TIME_WITH_TIMEZONE && sqlType != Types.TIMESTAMP_WITH_TIMEZONE; }
Example 12
Source File: ParseUtil.java From datacollector with Apache License 2.0 | 4 votes |
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: AbstractFieldMetaData.java From jaybird with GNU Lesser General Public License v2.1 | 4 votes |
protected final String getFieldClassName(int field) throws SQLException { switch (getFieldType(field)) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: return STRING_CLASS_NAME; case Types.SMALLINT: case Types.INTEGER: return INTEGER_CLASS_NAME; case Types.FLOAT: case Types.DOUBLE: return DOUBLE_CLASS_NAME; case Types.TIMESTAMP: return TIMESTAMP_CLASS_NAME; case Types.BLOB: return BLOB_CLASS_NAME; case Types.CLOB: return CLOB_CLASS_NAME; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: return BYTE_ARRAY_CLASS_NAME; case Types.ARRAY: return ARRAY_CLASS_NAME; case Types.BIGINT: return LONG_CLASS_NAME; case Types.TIME: return TIME_CLASS_NAME; case Types.DATE: return SQL_DATE_CLASS_NAME; case Types.TIME_WITH_TIMEZONE: return OFFSET_TIME_CLASS_NAME; case Types.TIMESTAMP_WITH_TIMEZONE: return OFFSET_DATE_TIME_CLASS_NAME; case Types.NUMERIC: case Types.DECIMAL: case JaybirdTypeCodes.DECFLOAT: return BIG_DECIMAL_CLASS_NAME; case Types.BOOLEAN: return BOOLEAN_CLASS_NAME; case Types.NULL: case Types.OTHER: return OBJECT_CLASS_NAME; case Types.ROWID: return ROW_ID_CLASS_NAME; default: throw new FBSQLException("Unknown SQL type.", SQLStateConstants.SQL_STATE_INVALID_PARAM_TYPE); } }
Example 14
Source File: JdbcTypeConverter.java From jaybird with GNU Lesser General Public License v2.1 | 4 votes |
/** * Converts from the Firebird type, subtype and scale to the JDBC type value from {@link java.sql.Types}. * <p> * This method is not capable of identifying {@link java.sql.Types#ROWID}; this will be identified * as {@link java.sql.Types#BINARY} instead. * </p> * * @param firebirdType * Firebird type value (from {@link ISCConstants} {@code SQL_*} with or without nullable bit set * @param subtype * Subtype * @param scale * Scale * @return JDBC type, or {@link Types#OTHER} for unknown types */ public static int fromFirebirdToJdbcType(int firebirdType, int subtype, int scale) { firebirdType = firebirdType & ~1; switch (firebirdType) { case ISCConstants.SQL_SHORT: case ISCConstants.SQL_LONG: case ISCConstants.SQL_INT64: case ISCConstants.SQL_DOUBLE: case ISCConstants.SQL_D_FLOAT: case ISCConstants.SQL_INT128: if (subtype == SUBTYPE_NUMERIC || (subtype == 0 && scale < 0)) { return Types.NUMERIC; } else if (subtype == SUBTYPE_DECIMAL) { return Types.DECIMAL; } else { switch (firebirdType) { case ISCConstants.SQL_SHORT: return Types.SMALLINT; case ISCConstants.SQL_LONG: return Types.INTEGER; case ISCConstants.SQL_INT64: return Types.BIGINT; case ISCConstants.SQL_DOUBLE: case ISCConstants.SQL_D_FLOAT: return Types.DOUBLE; case ISCConstants.SQL_INT128: return Types.DECIMAL; } } case ISCConstants.SQL_FLOAT: return Types.FLOAT; case ISCConstants.SQL_DEC16: case ISCConstants.SQL_DEC34: return JaybirdTypeCodes.DECFLOAT; case ISCConstants.SQL_TEXT: if (subtype == ISCConstants.CS_BINARY) { return Types.BINARY; } else { return Types.CHAR; } case ISCConstants.SQL_VARYING: if (subtype == ISCConstants.CS_BINARY) { return Types.VARBINARY; } else { return Types.VARCHAR; } case ISCConstants.SQL_TIMESTAMP: return Types.TIMESTAMP; case ISCConstants.SQL_TYPE_TIME: return Types.TIME; case ISCConstants.SQL_TYPE_DATE: return Types.DATE; case ISCConstants.SQL_TIMESTAMP_TZ: case ISCConstants.SQL_TIMESTAMP_TZ_EX: return Types.TIMESTAMP_WITH_TIMEZONE; case ISCConstants.SQL_TIME_TZ: case ISCConstants.SQL_TIME_TZ_EX: return Types.TIME_WITH_TIMEZONE; case ISCConstants.SQL_BLOB: if (subtype < 0) { return Types.BLOB; } else if (subtype == ISCConstants.BLOB_SUB_TYPE_TEXT) { return Types.LONGVARCHAR; } else { // if (subtype == 0 || subtype > 1) return Types.LONGVARBINARY; } case ISCConstants.SQL_BOOLEAN: return Types.BOOLEAN; case ISCConstants.SQL_NULL: return Types.NULL; case ISCConstants.SQL_ARRAY: return Types.ARRAY; case ISCConstants.SQL_QUAD: default: return Types.OTHER; } }
Example 15
Source File: TypeMetadata.java From jaybird with GNU Lesser General Public License v2.1 | 4 votes |
/** * Returns the column size (precision) of the type. * <p> * The value returned follows the definition used in {@link java.sql.DatabaseMetaData}, as established in * {@link java.sql.DatabaseMetaData#getColumns(String, String, String, String)} for {@code COLUMN_SIZE}. The same * definition is used for database metadata columns {@code PRECISION} in, among others, * {@link java.sql.DatabaseMetaData#getFunctionColumns(String, String, String, String)}. * </p> * <p> * This method will also return any non-zero precision information stored for other datatypes than those listed in * the {@code COLUMN_SIZE} definition in the JDBC API. * </p> * * @return The column size as defined in {@link java.sql.DatabaseMetaData}, or {@code null}. */ public Integer getColumnSize() { switch (jdbcType) { case Types.FLOAT: return isFloatBinaryPrecision() ? FLOAT_BINARY_PRECISION : FLOAT_DECIMAL_PRECISION; case Types.DOUBLE: return isFloatBinaryPrecision() ? DOUBLE_BINARY_PRECISION : DOUBLE_DECIMAL_PRECISION; case Types.CHAR: case Types.VARCHAR: case Types.BINARY: case Types.VARBINARY: return characterLength; case Types.BIGINT: return BIGINT_PRECISION; case Types.INTEGER: return INTEGER_PRECISION; case Types.SMALLINT: return SMALLINT_PRECISION; case Types.BOOLEAN: return BOOLEAN_BINARY_PRECISION; case Types.NUMERIC: case Types.DECIMAL: switch (type) { case double_type: case d_float_type: case int64_type: return coalesce(precision, NUMERIC_BIGINT_PRECISION); case integer_type: return coalesce(precision, NUMERIC_INTEGER_PRECISION); case smallint_type: return coalesce(precision, NUMERIC_SMALLINT_PRECISION); case int128_type: return coalesce(precision, NUMERIC_INT128_PRECISION); default: throw new IllegalStateException(String.format( "Incorrect derivation of NUMERIC/DECIMAL precision for jdbcType %d, type %d, subType %d, scale %d", jdbcType, type, subType, scale)); } case Types.DATE: return DATE_PRECISION; case Types.TIME: return TIME_PRECISION; case Types.TIMESTAMP: return TIMESTAMP_PRECISION; case Types.TIME_WITH_TIMEZONE: return TIME_WITH_TIMEZONE_PRECISION; case Types.TIMESTAMP_WITH_TIMEZONE: return TIMESTAMP_WITH_TIMEZONE_PRECISION; case JaybirdTypeCodes.DECFLOAT: switch (type) { case dec16_type: return DECFLOAT_16_PRECISION; case dec34_type: return DECFLOAT_34_PRECISION; default: throw new IllegalStateException(String.format( "Incorrect derivation of DECFLOAT precision for jdbcType %d, type %d, subType %d, scale %d", jdbcType, type, subType, scale)); } } // If we have non-default, non-zero precision, report it return coalesce(precision, 0) != 0 ? precision : null; }
Example 16
Source File: JdbcTypeHelper.java From SimpleFlatMapper with MIT License | 4 votes |
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 17
Source File: TypeConverter.java From jpa-entity-generator with MIT License | 4 votes |
public static String toJavaType(int typeCode) { switch (typeCode) { case Types.ARRAY: return "Array"; case Types.BIGINT: return "Long"; // case Types.BINARY: case Types.BIT: // return "Boolean"; return "boolean"; case Types.BLOB: return "Blob"; case Types.BOOLEAN: return "Boolean"; case Types.CHAR: return "String"; case Types.CLOB: return "Clob"; // case Types.DATALINK: case Types.DATE: return "Date"; case Types.DECIMAL: return "java.math.BigDecimal"; // case Types.DISTINCT: case Types.DOUBLE: return "Double"; case Types.FLOAT: return "Float"; case Types.INTEGER: return "Integer"; // case Types.JAVA_OBJECT: // case Types.LONGNVARCHAR: // case Types.LONGVARBINARY: case Types.LONGVARCHAR: return "String"; // case Types.NCHAR: // case Types.NCLOB: // case Types.NULL: case Types.NUMERIC: return "java.math.BigDecimal"; // case Types.NVARCHAR: // case Types.OTHER: case Types.REAL: return "Float"; case Types.REF: return "Ref"; // case Types.REF_CURSOR: // case Types.ROWID: case Types.SMALLINT: return "Short"; // case Types.SQLXML: case Types.STRUCT: return "Struct"; case Types.TIME: return "Time"; case Types.TIME_WITH_TIMEZONE: return "Time"; case Types.TIMESTAMP: return "Timestamp"; case Types.TIMESTAMP_WITH_TIMEZONE: return "Timestamp"; case Types.TINYINT: return "Byte"; // case Types.VARBINARY: case Types.VARCHAR: return "String"; default: return "String"; } }
Example 18
Source File: ResultSetRecordSet.java From nifi with Apache License 2.0 | 4 votes |
private static RecordFieldType getFieldType(final int sqlType, final String valueClassName) { switch (sqlType) { case Types.BIGINT: case Types.ROWID: return RecordFieldType.LONG; case Types.BIT: case Types.BOOLEAN: return RecordFieldType.BOOLEAN; case Types.CHAR: return RecordFieldType.CHAR; case Types.DATE: return RecordFieldType.DATE; case Types.NUMERIC: case Types.DECIMAL: return RecordFieldType.DECIMAL; case Types.DOUBLE: case Types.REAL: return RecordFieldType.DOUBLE; case Types.FLOAT: return RecordFieldType.FLOAT; case Types.INTEGER: return RecordFieldType.INT; case Types.SMALLINT: return RecordFieldType.SHORT; case Types.TINYINT: return RecordFieldType.BYTE; case Types.LONGNVARCHAR: case Types.LONGVARCHAR: case Types.NCHAR: case Types.NULL: case Types.NVARCHAR: case Types.VARCHAR: return RecordFieldType.STRING; case Types.OTHER: case Types.JAVA_OBJECT: if (STRING_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.STRING; } if (INT_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.INT; } if (LONG_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.LONG; } if (DATE_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.DATE; } if (FLOAT_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.FLOAT; } if (DOUBLE_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.DOUBLE; } if (BIGDECIMAL_CLASS_NAME.equals(valueClassName)) { return RecordFieldType.DECIMAL; } return RecordFieldType.RECORD; case Types.TIME: case Types.TIME_WITH_TIMEZONE: return RecordFieldType.TIME; case Types.TIMESTAMP: case Types.TIMESTAMP_WITH_TIMEZONE: case -101: // Oracle's TIMESTAMP WITH TIME ZONE case -102: // Oracle's TIMESTAMP WITH LOCAL TIME ZONE return RecordFieldType.TIMESTAMP; } return RecordFieldType.STRING; }
Example 19
Source File: ColumnJdbcTable.java From presto with Apache License 2.0 | 4 votes |
static int jdbcDataType(Type type) { if (type.equals(BOOLEAN)) { return Types.BOOLEAN; } if (type.equals(BIGINT)) { return Types.BIGINT; } if (type.equals(INTEGER)) { return Types.INTEGER; } if (type.equals(SMALLINT)) { return Types.SMALLINT; } if (type.equals(TINYINT)) { return Types.TINYINT; } if (type.equals(REAL)) { return Types.REAL; } if (type.equals(DOUBLE)) { return Types.DOUBLE; } if (type instanceof DecimalType) { return Types.DECIMAL; } if (isVarcharType(type)) { return Types.VARCHAR; } if (isCharType(type)) { return Types.CHAR; } if (type.equals(VARBINARY)) { return Types.VARBINARY; } if (type.equals(TIME)) { return Types.TIME; } if (type.equals(TIME_WITH_TIME_ZONE)) { return Types.TIME_WITH_TIMEZONE; } if (type.equals(TIMESTAMP)) { return Types.TIMESTAMP; } if (type.equals(TIMESTAMP_WITH_TIME_ZONE)) { return Types.TIMESTAMP_WITH_TIMEZONE; } if (type.equals(DATE)) { return Types.DATE; } if (type instanceof ArrayType) { return Types.ARRAY; } return Types.JAVA_OBJECT; }