Java Code Examples for java.sql.Types#STRUCT
The following examples show how to use
java.sql.Types#STRUCT .
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: MultiShardStatement.java From elastic-db-tools-for-java with MIT License | 6 votes |
@Override public void run() { SQLServerPreparedStatement stmt = (SQLServerPreparedStatement) statement; try { switch (type) { // TODO: Add all types case Types.STRUCT: if (objects.length == 2) { stmt.setStructured(index, (String) objects[0], (SQLServerDataTable) objects[1]); } break; default: throw new RuntimeException("Not Supported yet!", new UnsupportedOperationException(String.format("This SQL Type (%1$s) cannot be added to the statement using this" + " method. Please add the same as an inline parameter at %2$s index.", type, index))); } } catch (SQLServerException ex) { throw new RuntimeException(ex); } }
Example 2
Source File: DB2XMLWriter.java From iaf with Apache License 2.0 | 5 votes |
public static String getFieldType (int type) { switch (type) { case Types.INTEGER : return ("INTEGER"); case Types.NUMERIC : return ("NUMERIC"); case Types.CHAR : return ("CHAR"); case Types.DATE : return ("DATE"); case Types.TIMESTAMP : return ("TIMESTAMP"); case Types.DOUBLE : return ("DOUBLE"); case Types.FLOAT : return ("FLOAT"); case Types.ARRAY : return ("ARRAY"); case Types.BLOB : return ("BLOB"); case Types.CLOB : return ("CLOB"); case Types.DISTINCT : return ("DISTINCT"); case Types.LONGVARBINARY : return ("LONGVARBINARY"); case Types.VARBINARY : return ("VARBINARY"); case Types.BINARY : return ("BINARY"); case Types.REF : return ("REF"); case Types.STRUCT : return ("STRUCT"); case Types.JAVA_OBJECT : return ("JAVA_OBJECT"); case Types.VARCHAR : return ("VARCHAR"); case Types.TINYINT: return ("TINYINT"); case Types.TIME: return ("TIME"); case Types.REAL: return ("REAL"); case Types.BOOLEAN: return ("BOOLEAN"); case Types.BIT: return ("BIT"); case Types.BIGINT: return ("BIGINT"); case Types.SMALLINT: return ("SMALLINT"); } return ("Unknown"); }
Example 3
Source File: EmbedPreparedStatement.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * 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 4
Source File: EmbedPreparedStatement.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * 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: ResultSetUtil.java From tajo with Apache License 2.0 | 5 votes |
public static int columnDisplaySize(int columnType) throws SQLException { switch (columnType) { case Types.BIT: case Types.BOOLEAN: case Types.CHAR: case Types.VARCHAR: return columnPrecision(columnType); case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: return columnPrecision(columnType) + 1; // allow +/- case Types.TIMESTAMP: case Types.DATE: case Types.TIME: return columnPrecision(columnType); // see http://download.oracle.com/javase/6/docs/api/constant-values.html#java.lang.Float.MAX_EXPONENT case Types.FLOAT: return 24; // e.g. -(17#).e-### // see http://download.oracle.com/javase/6/docs/api/constant-values.html#java.lang.Double.MAX_EXPONENT case Types.DOUBLE: return 25; // e.g. -(17#).e-#### case Types.DECIMAL: return Integer.MAX_VALUE; case Types.NULL: return 4; case Types.BLOB: case Types.BINARY: case Types.ARRAY: case Types.STRUCT: default: return 0; //unknown width } }
Example 6
Source File: JDBCTypeMapper.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 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"; default: return null; } }
Example 7
Source File: ResultSetUtil.java From tajo with Apache License 2.0 | 5 votes |
public static int tajoTypeToSqlType(DataType type) throws SQLException { switch (type.getType()) { case BIT: return Types.BIT; case BOOLEAN: return Types.BOOLEAN; case INT1: return Types.TINYINT; case INT2: return Types.SMALLINT; case INT4: return Types.INTEGER; case INT8: return Types.BIGINT; case FLOAT4: return Types.FLOAT; case FLOAT8: return Types.DOUBLE; case NUMERIC: return Types.NUMERIC; case DATE: return Types.DATE; case TIMESTAMP: return Types.TIMESTAMP; case TIME: return Types.TIME; case CHAR: case VARCHAR: case TEXT: return Types.VARCHAR; case BLOB: return Types.BLOB; case RECORD: return Types.STRUCT; case NULL_TYPE: return Types.NULL; default: throw new SQLException("Unrecognized column type: " + type); } }
Example 8
Source File: AbstractJdbcSpecific.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 4 votes |
@Override public char sqlType2jetel(int sqlType) { switch (sqlType) { case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: return DataFieldType.INTEGER.getShortName(); //------------------- case Types.BIGINT: return DataFieldType.LONG.getShortName(); //------------------- case Types.DECIMAL: case Types.NUMERIC: return DataFieldType.DECIMAL.getShortName(); case Types.DOUBLE: case Types.FLOAT: case Types.REAL: return DataFieldType.NUMBER.getShortName(); //------------------ case Types.CHAR: case Types.LONGVARCHAR: case Types.VARCHAR: case Types.CLOB: case Types.NCHAR: case Types.NVARCHAR: case Types.NCLOB: return DataFieldType.STRING.getShortName(); //------------------ case Types.DATE: case Types.TIME: case Types.TIMESTAMP: return DataFieldType.DATE.getShortName(); //----------------- case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: case Types.BLOB: case Types.OTHER: return DataFieldType.BYTE.getShortName(); //----------------- case Types.BOOLEAN: return DataFieldType.BOOLEAN.getShortName(); // proximity assignment case Types.BIT: case Types.NULL: return DataFieldType.STRING.getShortName(); case Types.STRUCT: throw new IllegalArgumentException("Can't handle JDBC type STRUCT"); default: throw new IllegalArgumentException("Can't handle JDBC.Type :"+sqlType); } }
Example 9
Source File: Converters.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * 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; } }
Example 10
Source File: QuarkMetaResultSet.java From quark with Apache License 2.0 | 4 votes |
private static Object getValue(ResultSet resultSet, int type, int j, Calendar calendar) throws SQLException { switch (type) { case Types.BIGINT: final long aLong = resultSet.getLong(j + 1); return aLong == 0 && resultSet.wasNull() ? null : aLong; case Types.INTEGER: final int anInt = resultSet.getInt(j + 1); return anInt == 0 && resultSet.wasNull() ? null : anInt; case Types.SMALLINT: final short aShort = resultSet.getShort(j + 1); return aShort == 0 && resultSet.wasNull() ? null : aShort; case Types.TINYINT: final byte aByte = resultSet.getByte(j + 1); return aByte == 0 && resultSet.wasNull() ? null : aByte; case Types.DOUBLE: case Types.FLOAT: final double aDouble = resultSet.getDouble(j + 1); return aDouble == 0D && resultSet.wasNull() ? null : aDouble; case Types.REAL: final float aFloat = resultSet.getFloat(j + 1); return aFloat == 0D && resultSet.wasNull() ? null : aFloat; case Types.DATE: final Date aDate = resultSet.getDate(j + 1, calendar); return aDate == null ? null : (int) (aDate.getTime() / DateTimeUtils.MILLIS_PER_DAY); case Types.TIME: final Time aTime = resultSet.getTime(j + 1, calendar); return aTime == null ? null : (int) (aTime.getTime() % DateTimeUtils.MILLIS_PER_DAY); case Types.TIMESTAMP: final Timestamp aTimestamp = resultSet.getTimestamp(j + 1, calendar); return aTimestamp == null ? null : aTimestamp.getTime(); case Types.ARRAY: final Array array = resultSet.getArray(j + 1); if (null == array) { return null; } ResultSet arrayValues = array.getResultSet(); TreeMap<Integer, Object> map = new TreeMap<>(); while (arrayValues.next()) { // column 1 is the index in the array, column 2 is the value. // Recurse on `getValue` to unwrap nested types correctly. // `j` is zero-indexed and incremented for us, thus we have `1` being used twice. map.put(arrayValues.getInt(1), getValue(arrayValues, array.getBaseType(), 1, calendar)); } // If the result set is not in the same order as the actual Array, TreeMap fixes that. // Need to make a concrete list to ensure Jackson serialization. //return new ListLike<Object>(new ArrayList<>(map.values()), ListLikeType.ARRAY); return new ArrayList<>(map.values()); case Types.STRUCT: Struct struct = resultSet.getObject(j + 1, Struct.class); Object[] attrs = struct.getAttributes(); List<Object> list = new ArrayList<>(attrs.length); for (Object o : attrs) { list.add(o); } return list; default: return resultSet.getObject(j + 1); } }
Example 11
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; } }
Example 12
Source File: SqoopHCatUtilities.java From aliyun-maxcompute-data-collectors with Apache License 2.0 | 4 votes |
public static String sqlTypeString(int sqlType) { switch (sqlType) { case Types.BIT: return "BIT"; case Types.TINYINT: return "TINYINT"; case Types.SMALLINT: return "SMALLINT"; case Types.INTEGER: return "INTEGER"; case Types.BIGINT: return "BIGINT"; case Types.FLOAT: return "FLOAT"; case Types.REAL: return "REAL"; case Types.DOUBLE: return "DOUBLE"; case Types.NUMERIC: return "NUMERIC"; case Types.DECIMAL: return "DECIMAL"; case Types.CHAR: return "CHAR"; case Types.VARCHAR: return "VARCHAR"; case Types.LONGVARCHAR: return "LONGVARCHAR"; case Types.DATE: return "DATE"; case Types.TIME: return "TIME"; case Types.TIMESTAMP: return "TIMESTAMP"; case Types.BINARY: return "BINARY"; case Types.VARBINARY: return "VARBINARY"; case Types.LONGVARBINARY: return "LONGVARBINARY"; case Types.NULL: return "NULL"; case Types.OTHER: return "OTHER"; case Types.JAVA_OBJECT: return "JAVA_OBJECT"; case Types.DISTINCT: return "DISTINCT"; case Types.STRUCT: return "STRUCT"; case Types.ARRAY: return "ARRAY"; case Types.BLOB: return "BLOB"; case Types.CLOB: return "CLOB"; case Types.REF: return "REF"; case Types.DATALINK: return "DATALINK"; case Types.BOOLEAN: return "BOOLEAN"; case Types.ROWID: return "ROWID"; case Types.NCHAR: return "NCHAR"; case Types.NVARCHAR: return "NVARCHAR"; case Types.LONGNVARCHAR: return "LONGNVARCHAR"; case Types.NCLOB: return "NCLOB"; case Types.SQLXML: return "SQLXML"; default: return "<UNKNOWN>"; } }
Example 13
Source File: AttributeSetup.java From celerio with Apache License 2.0 | 4 votes |
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 14
Source File: SQLTableModel.java From nordpos with GNU General Public License v3.0 | 4 votes |
/** Creates a new instance of SQLTableModel */ public SQLTableModel(DataField[] df) { m_aRows = new ArrayList(); m_df = df; m_classes = new Datas[df.length]; for (int i = 0; i < df.length; i++) { switch (df[i].Type) { case Types.INTEGER: case Types.BIGINT: case Types.SMALLINT: case Types.TINYINT: m_classes[i] = Datas.INT; break; case Types.BIT: case Types.BOOLEAN: m_classes[i] = Datas.BOOLEAN; break; case Types.DECIMAL: case Types.DOUBLE: case Types.FLOAT: case Types.REAL: case Types.NUMERIC: m_classes[i] = Datas.DOUBLE; break; case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: case Types.CLOB: m_classes[i] = Datas.STRING; break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: m_classes[i] = Datas.TIMESTAMP; break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: case Types.BLOB: m_classes[i] = Datas.BYTES; break; case Types.ARRAY: case Types.DATALINK: case Types.DISTINCT: case Types.JAVA_OBJECT: case Types.NULL: case Types.OTHER: case Types.REF: case Types.STRUCT: default: m_classes[i] = Datas.OBJECT; break; } } }
Example 15
Source File: AvaticaSite.java From calcite-avatica with Apache License 2.0 | 4 votes |
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 16
Source File: JDBCUtils.java From netbeans with Apache License 2.0 | 4 votes |
/** * Get the SQLType for the given java.sql.Type type. * * @param type the java.sql.Type type specifier * @return SQLType.the SQLType for this java.sql.Type, or null if it's not recognized */ public static SQLType getSQLType(int type) { switch (type) { case Types.BIT: return SQLType.BIT; case Types.TINYINT: return SQLType.TINYINT; case Types.SMALLINT: return SQLType.SMALLINT; case Types.INTEGER: return SQLType.INTEGER; case Types.BIGINT: return SQLType.BIGINT; case Types.FLOAT: return SQLType.FLOAT; case Types.REAL: return SQLType.REAL; case Types.DOUBLE: return SQLType.DOUBLE; case Types.NUMERIC: return SQLType.NUMERIC; case Types.DECIMAL: return SQLType.DECIMAL; case Types.CHAR: return SQLType.CHAR; case Types.VARCHAR: return SQLType.VARCHAR; case Types.LONGVARCHAR: return SQLType.LONGVARCHAR; case Types.DATE: return SQLType.DATE; case Types.TIME: return SQLType.TIME; case Types.TIMESTAMP: return SQLType.TIMESTAMP; case Types.BINARY: return SQLType.BINARY; case Types.VARBINARY: return SQLType.VARBINARY; case Types.LONGVARBINARY: return SQLType.LONGVARBINARY; case Types.NULL: return SQLType.NULL; case Types.OTHER: return SQLType.OTHER; case Types.JAVA_OBJECT: return SQLType.JAVA_OBJECT; case Types.DISTINCT: return SQLType.DISTINCT; case Types.STRUCT: return SQLType.STRUCT; case Types.ARRAY: return SQLType.ARRAY; case Types.BLOB: return SQLType.BLOB; case Types.CLOB: return SQLType.CLOB; case Types.REF: return SQLType.REF; case Types.DATALINK: return SQLType.DATALINK; case Types.BOOLEAN: return SQLType.BOOLEAN; case Types.LONGNVARCHAR: return SQLType.LONGVARCHAR; case Types.NCHAR: return SQLType.CHAR; case Types.NCLOB: return SQLType.CLOB; case Types.NVARCHAR: return SQLType.VARCHAR; case Types.SQLXML: return SQLType.SQLXML; case Types.ROWID: return SQLType.ROWID; default: Logger.getLogger(JDBCUtils.class.getName()).log(Level.WARNING, "Unknown JDBC column type: " + type + ". Returns null."); return null; } }
Example 17
Source File: GeometryConverterAdapter.java From importer-exporter with Apache License 2.0 | 4 votes |
@Override public int getNullGeometryType() { return Types.STRUCT; }
Example 18
Source File: AvaticaSite.java From calcite-avatica with Apache License 2.0 | 4 votes |
/** 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 19
Source File: JdbcTypesUtils.java From pxf with Apache License 2.0 | 4 votes |
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 20
Source File: DatabaseStatement.java From sndml3 with MIT License | 4 votes |
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); } }