Java Code Examples for java.sql.Types#SQLXML
The following examples show how to use
java.sql.Types#SQLXML .
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: GfxdCBArgForSynchPrms.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
private int mapSQLType(int sqlType) throws IllegalStateException { switch (sqlType) { case Types.JAVA_OBJECT: return JAVA_OBJECT; case Types.BLOB: return BLOB; case Types.CLOB: return CLOB; case Types.SQLXML: return SQLXML; case JDBC40Translation.JSON: return JSON; default: if (sqlType < Byte.MIN_VALUE || sqlType > Byte.MAX_VALUE) { throw new IllegalStateException("Sql type =" + sqlType + " not supported as it exceeds Byte limit "); } else { return sqlType; } } }
Example 2
Source File: MatchedColumnsHelper.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public List<ColumnInfo> getNonClobBlobXmlTypeColumns(TableInfo table, int numCols) { List<ColumnInfo> columns = table.getColumnList(); int colCnt = columns.size(); List<ColumnInfo> partColumns = new ArrayList<ColumnInfo>(); for (int i = 0; i < numCols; i++) { ColumnInfo col = null; boolean f = false; for (int j = 0; j < 10 && !f; j++) { col = columns.get(random.nextInt(colCnt)); if (col.getColumnType() != Types.BLOB && col.getColumnType() != Types.CLOB && col.getColumnType() != Types.SQLXML && !partColumns.contains(col)) { f = true; } } if (f) partColumns.add(col); } return partColumns; }
Example 3
Source File: MatchedColumnsHelper.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public List<ColumnInfo> getNonClobBlobXmlTypeColumns(TableInfo table, int numCols) { List<ColumnInfo> columns = table.getColumnList(); int colCnt = columns.size(); List<ColumnInfo> partColumns = new ArrayList<ColumnInfo>(); for (int i = 0; i < numCols; i++) { ColumnInfo col = null; boolean f = false; for (int j = 0; j < 10 && !f; j++) { col = columns.get(random.nextInt(colCnt)); if (col.getColumnType() != Types.BLOB && col.getColumnType() != Types.CLOB && col.getColumnType() != Types.SQLXML && !partColumns.contains(col)) { f = true; } } if (f) partColumns.add(col); } return partColumns; }
Example 4
Source File: GfxdCBArgForSynchPrms.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
private int mapSQLType(int sqlType) throws IllegalStateException { switch (sqlType) { case Types.JAVA_OBJECT: return JAVA_OBJECT; case Types.BLOB: return BLOB; case Types.CLOB: return CLOB; case Types.SQLXML: return SQLXML; case JDBC40Translation.JSON: return JSON; default: if (sqlType < Byte.MIN_VALUE || sqlType > Byte.MAX_VALUE) { throw new IllegalStateException("Sql type =" + sqlType + " not supported as it exceeds Byte limit "); } else { return sqlType; } } }
Example 5
Source File: GfxdCBArgForSynchPrms.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public boolean isCaseSensitive(int column) throws SQLException { if (column > 0 && column <= this.numParams) { final int sqlType; if (this.dtds != null) { sqlType = this.dtds[column - 1].getTypeId().getJDBCTypeId(); } else { // don't need to map the type since the remapped types will never be // true in the call below sqlType = this.sqlParamTypes[column - 1]; } switch (sqlType) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: case Types.CLOB: case Types.SQLXML: return true; default: return false; } } else { throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FOUND, Integer.valueOf(column)); } }
Example 6
Source File: GfxdCBArgForSynchPrms.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public int getColumnType(int column) throws SQLException { if (column > 0 && column <= this.numParams) { if (this.dtds != null) { return this.dtds[column - 1].getTypeId().getJDBCTypeId(); } else { final byte sqlType = this.sqlParamTypes[column - 1]; switch (sqlType) { case BLOB: return Types.BLOB; case CLOB: return Types.CLOB; case JAVA_OBJECT: return Types.JAVA_OBJECT; case SQLXML: return Types.SQLXML; case JSON: return JDBC40Translation.JSON; default: return sqlType; } } } else { throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FOUND, Integer.valueOf(column)); } }
Example 7
Source File: GfxdCBArgForSynchPrms.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public int getColumnType(int column) throws SQLException { if (column > 0 && column <= this.numParams) { if (this.dtds != null) { return this.dtds[column - 1].getTypeId().getJDBCTypeId(); } else { final byte sqlType = this.sqlParamTypes[column - 1]; switch (sqlType) { case BLOB: return Types.BLOB; case CLOB: return Types.CLOB; case JAVA_OBJECT: return Types.JAVA_OBJECT; case SQLXML: return Types.SQLXML; case JSON: return JDBC40Translation.JSON; default: return sqlType; } } } else { throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FOUND, Integer.valueOf(column)); } }
Example 8
Source File: GfxdCBArgForSynchPrms.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public boolean isCaseSensitive(int column) throws SQLException { if (column > 0 && column <= this.numParams) { final int sqlType; if (this.dtds != null) { sqlType = this.dtds[column - 1].getTypeId().getJDBCTypeId(); } else { // don't need to map the type since the remapped types will never be // true in the call below sqlType = this.sqlParamTypes[column - 1]; } switch (sqlType) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: case Types.CLOB: case Types.SQLXML: return true; default: return false; } } else { throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FOUND, Integer.valueOf(column)); } }
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: PostgreSQLColumnMetadataReaderTest.java From virtual-schemas with MIT License | 4 votes |
@ValueSource(ints = { Types.SQLXML, Types.DISTINCT }) @ParameterizedTest void testMapJdbcTypeFallbackToMaxVarChar(final int type) { assertThat(mapJdbcType(type), equalTo(DataType.createMaximumSizeVarChar(DataType.ExaCharset.UTF8))); }
Example 11
Source File: TypeMapper.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
private static Class mapSQLType( final int t ) { switch ( t ) { case Types.ARRAY: return Object[].class; case Types.BIGINT: return Long.class; case Types.BINARY: return byteArrayClass; case Types.BIT: return Boolean.class; case Types.BLOB: return Blob.class; case Types.BOOLEAN: // Types.BOOLEAN was not part of JDK1.2.2 return Boolean.class; case Types.CHAR: return String.class; case Types.CLOB: return Clob.class; case Types.DATALINK: // Types.DATALINK was not part of JDK 1.2.2 return URL.class; case Types.DATE: return java.sql.Date.class; case Types.DECIMAL: return java.math.BigDecimal.class; case Types.DISTINCT: return Object.class; case Types.DOUBLE: return Double.class; case Types.FLOAT: return Double.class; case Types.INTEGER: return Integer.class; case Types.JAVA_OBJECT: return Object.class; case Types.LONGVARBINARY: return byteArrayClass; case Types.LONGVARCHAR: return String.class; case Types.NCLOB: return NClob.class; case Types.NULL: return Object.class; case Types.NUMERIC: return java.math.BigDecimal.class; case Types.NCHAR: case Types.NVARCHAR: case Types.LONGNVARCHAR: return String.class; case Types.OTHER: return Object.class; case Types.REAL: return Float.class; case Types.REF: return Ref.class; case Types.ROWID: return RowId.class; case Types.SMALLINT: return Short.class; case Types.STRUCT: return Struct.class; case Types.SQLXML: return SQLXML.class; case Types.TIME: return Time.class; case Types.TIMESTAMP: return Timestamp.class; case Types.TINYINT: return Byte.class; case Types.VARBINARY: return byteArrayClass; case Types.VARCHAR: return String.class; default: return Object.class; } }
Example 12
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 13
Source File: JdbcBroker.java From geoportal-server-harvester with Apache License 2.0 | 4 votes |
private void createRecordIdSetter() throws DataProcessorException { try { ResultSetMetaData metaData = resultSet.getMetaData(); for (int i=1; i<= metaData.getColumnCount(); i++) { final String columnName = metaData.getColumnName(i); final int columnType = metaData.getColumnType(i); if (columnName.equalsIgnoreCase(definition.getFileIdColumn())) { switch (columnType) { case Types.VARCHAR: case Types.CHAR: case Types.LONGVARCHAR: case Types.LONGNVARCHAR: case Types.NVARCHAR: case Types.NCHAR: case Types.SQLXML: idSetter = (st, id)-> st.setString(1, id); break; case Types.DOUBLE: idSetter = (st, id)-> st.setDouble(1, NumberUtils.toDouble(id)); break; case Types.FLOAT: idSetter = (st, id)-> st.setFloat(1, NumberUtils.toFloat(id)); break; case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: case Types.BIGINT: case Types.DECIMAL: case Types.NUMERIC: idSetter = (st, id)-> st.setInt(1, NumberUtils.toInt(id)); break; } break; } } } catch (SQLException ex) { throw new DataProcessorException(String.format("Error opening JDBC connection to: %s", definition.getConnection()), ex); } }
Example 14
Source File: JdbcBroker.java From geoportal-server-harvester with Apache License 2.0 | 4 votes |
private List<AttributeInjector> createAttributeInjectors(final String columnName, final int columnType) { List<AttributeInjector> attributeInjectors = new ArrayList<>(); switch (columnType) { case Types.VARCHAR: case Types.CHAR: case Types.LONGVARCHAR: case Types.LONGNVARCHAR: case Types.NVARCHAR: case Types.NCHAR: case Types.SQLXML: createAttributeNames("src_%s_txt", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->{ if (!name.endsWith("_xml")) { a.put(name, readValue(r, columnName, String.class)); } else { x.xml = readValue(r, columnName, String.class); } })); break; case Types.DOUBLE: createAttributeNames("src_%s_d", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->a.put(name, readValue(r, columnName, Double.class)))); break; case Types.FLOAT: createAttributeNames("src_%s_f", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->a.put(name, readValue(r, columnName, Float.class)))); break; case Types.INTEGER: createAttributeNames("src_%s_i", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->a.put(name, readValue(r, columnName, Integer.class)))); break; case Types.SMALLINT: case Types.TINYINT: createAttributeNames("src_%s_i", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->a.put(name, readValue(r, columnName, Short.class)))); break; case Types.BIGINT: case Types.DECIMAL: case Types.NUMERIC: createAttributeNames("src_%s_d", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->a.put(name, readValue(r, columnName, BigDecimal.class)))); break; case Types.BOOLEAN: createAttributeNames("src_%s_b", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->a.put(name, readValue(r, columnName, Boolean.class)))); break; case Types.DATE: createAttributeNames("src_%s_dt", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->a.put(name, formatIsoDate(r.getDate(columnName))))); break; case Types.TIME: createAttributeNames("src_%s_dt", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->a.put(name, formatIsoDate(r.getTime(columnName))))); break; case Types.TIMESTAMP: createAttributeNames("src_%s_dt", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->a.put(name, formatIsoDate(r.getTimestamp(columnName))))); break; case Types.CLOB: createAttributeNames("src_%s_txt", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->{ if (!name.endsWith("_xml")) { a.put(name, formatClob(r.getClob(columnName))); } else { x.xml = formatClob(r.getClob(columnName)); } })); break; case Types.BLOB: case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: if (columnMappings.containsKey(norm(columnName)) && columnMappings.get(norm(columnName)).endsWith("_txt")) { createAttributeNames("src_%s_txt", norm(columnName)).forEach( name -> attributeInjectors.add((a,x,r)->a.put(name, formatBlob(r.getBlob(columnName))))); } break; } return attributeInjectors; }
Example 15
Source File: TypeId.java From Oceanus with Apache License 2.0 | 4 votes |
/** * Get a TypeId of the given JDBC type. This factory method is * intended to be used for built-in types. For user-defined types, * we will need a factory method that takes a Java type name. * * @param JDBCTypeId The JDBC Id of the type, as listed in * java.sql.Types * * @return The appropriate TypeId, or null if there is no such * TypeId. */ public static TypeId getBuiltInTypeId(int JDBCTypeId) { switch (JDBCTypeId) { case Types.TINYINT: return TINYINT_ID; case Types.SMALLINT: return SMALLINT_ID; case Types.INTEGER: return INTEGER_ID; case Types.BIGINT: return BIGINT_ID; case Types.FLOAT: case Types.REAL: return REAL_ID; case Types.DOUBLE: return DOUBLE_ID; case Types.DECIMAL: return DECIMAL_ID; case Types.NUMERIC: return NUMERIC_ID; case Types.CHAR: return CHAR_ID; case Types.VARCHAR: return VARCHAR_ID; case Types.DATE: return DATE_ID; case Types.TIME: return TIME_ID; case Types.TIMESTAMP: return TIMESTAMP_ID; case Types.BIT: case Types.BOOLEAN: return BOOLEAN_ID; case Types.BINARY: return BIT_ID; case Types.VARBINARY: return VARBIT_ID; case Types.LONGVARBINARY: return LONGVARBIT_ID; case Types.LONGVARCHAR: return LONGVARCHAR_ID; case Types.BLOB: return BLOB_ID; case Types.CLOB: return CLOB_ID; case Types.SQLXML: // 2009 return XML_ID; case Types.NCHAR: return NATIONAL_CHAR_ID; case Types.NVARCHAR: return NATIONAL_VARCHAR_ID; case Types.NCLOB: return NATIONAL_LONGVARCHAR_ID; default: return null; } }
Example 16
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 17
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 18
Source File: ClientTypes.java From vertx-sql-client with Apache License 2.0 | 4 votes |
public static String getTypeString(int type) { switch (type) { case BIGINT: return "BIGINT"; case BINARY: return "BINARY"; case BLOB: return "BLOB"; case BIT: case BOOLEAN: return "BOOLEAN"; case CHAR: return "CHAR"; case CLOB: return "CLOB"; case DATE: return "DATE"; case DECIMAL: return "DECIMAL"; case DOUBLE: return "DOUBLE"; case INTEGER: return "INTEGER"; case LONGVARBINARY: return "LONGVARBINARY"; case LONGVARCHAR: return "LONGVARCHAR"; case REAL: return "REAL"; case SMALLINT: return "SMALLINT"; case TIME: return "TIME"; case TIMESTAMP: return "TIMESTAMP"; case VARBINARY: return "VARBINARY"; case VARCHAR: return "VARCHAR"; case ROWID: return "ROWID"; // Types we don't support: case Types.ARRAY: return "ARRAY"; case Types.DATALINK: return "DATALINK"; case Types.REF: return "REF"; case Types.SQLXML: return "SQLXML"; case Types.STRUCT: return "STRUCT"; // Unknown type: default: return "UNKNOWN(" + type + ")"; } }
Example 19
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 20
Source File: ValueBinderExpressionVisitorAdapter.java From spanner-jdbc with MIT License | 4 votes |
private R setNullValue(Integer sqlType) { if (sqlType == null) { return binder.to((String) null); } switch (sqlType) { case Types.BIGINT: return binder.to((Long) null); case Types.BINARY: return binder.to((ByteArray) null); case Types.BLOB: return binder.to((ByteArray) null); case Types.BOOLEAN: return binder.to((Boolean) null); case Types.CHAR: return binder.to((String) null); case Types.CLOB: return binder.to((String) null); case Types.DATE: return binder.to((com.google.cloud.Date) null); case Types.DECIMAL: return binder.to((Double) null); case Types.DOUBLE: return binder.to((Double) null); case Types.FLOAT: return binder.to((Double) null); case Types.INTEGER: return binder.to((Long) null); case Types.LONGNVARCHAR: return binder.to((String) null); case Types.LONGVARBINARY: return binder.to((ByteArray) null); case Types.LONGVARCHAR: return binder.to((String) null); case Types.NCHAR: return binder.to((String) null); case Types.NCLOB: return binder.to((String) null); case Types.NUMERIC: return binder.to((Double) null); case Types.NVARCHAR: return binder.to((String) null); case Types.REAL: return binder.to((Double) null); case Types.SMALLINT: return binder.to((Long) null); case Types.SQLXML: return binder.to((String) null); case Types.TIME: return binder.to((com.google.cloud.Timestamp) null); case Types.TIMESTAMP: return binder.to((com.google.cloud.Timestamp) null); case Types.TINYINT: return binder.to((Long) null); case Types.VARBINARY: return binder.to((ByteArray) null); case Types.VARCHAR: return binder.to((String) null); default: throw new IllegalArgumentException("Unsupported sql type for setting to null: " + sqlType); } }