Java Code Examples for java.sql.Types#OTHER
The following examples show how to use
java.sql.Types#OTHER .
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: SqlMakeTools.java From GyJdbc with Apache License 2.0 | 6 votes |
private static int getTypes(Field arg) { arg.setAccessible(true); // 暴力反射 if (String.class.equals(arg.getType())) { return Types.VARCHAR; } else if (int.class.equals(arg.getType()) || Integer.class.equals(arg.getType())) { return Types.INTEGER; } else if (double.class.equals(arg.getType()) || Double.class.equals(arg.getType())) { return Types.DOUBLE; } else if (java.util.Date.class.isAssignableFrom(arg.getType())) { return Types.TIMESTAMP; } else if (long.class.equals(arg.getType()) || Long.class.equals(arg.getType())) { return Types.BIGINT; } else if (float.class.equals(arg.getType()) || Float.class.equals(arg.getType())) { return Types.FLOAT; } else if (boolean.class.equals(arg.getType()) || Boolean.class.equals(arg.getType())) { return Types.BOOLEAN; } else if (short.class.equals(arg.getType()) || Short.class.equals(arg.getType())) { return Types.INTEGER; } else if (byte.class.equals(arg.getType()) || Byte.class.equals(arg.getType())) { return Types.INTEGER; } else if (BigDecimal.class.equals(arg.getType())) { return Types.DECIMAL; } else { return Types.OTHER; } }
Example 2
Source File: DatabaseUtil.java From nextreports-server with Apache License 2.0 | 6 votes |
public static String getJavaType(int jdbcType) { switch (jdbcType) { case Types.BIT: return Boolean.class.getName(); case Types.TINYINT: return Byte.class.getName(); case Types.SMALLINT: return Short.class.getName(); case Types.CHAR: return String.class.getName(); case Types.VARCHAR: return String.class.getName(); case Types.DATE: return Date.class.getName(); case Types.TIME: return Time.class.getName(); case Types.TIMESTAMP: return Timestamp.class.getName(); case Types.DOUBLE: return Double.class.getName(); case Types.FLOAT: return Float.class.getName(); case Types.INTEGER: return Integer.class.getName(); case Types.BIGINT: return BigInteger.class.getName(); case Types.NUMERIC: return BigDecimal.class.getName(); case Types.DECIMAL: return BigDecimal.class.getName(); case Types.BINARY: return byte[].class.getName(); case Types.VARBINARY: return byte[].class.getName(); case Types.OTHER: return Object.class.getName(); default: return String.class.getName(); } }
Example 3
Source File: AnnotationCollectionStoreRepositoryJDBCImplTest.java From elucidate-server with MIT License | 6 votes |
@Test @SuppressWarnings("serial") public void testCreateAnnotationCollection() throws Exception { W3CAnnotationCollection w3cAnnotationCollection = generateRandomW3CAnnotationCollection(); String collectionId = w3cAnnotationCollection.getCollectionId(); Map<String, Object> jsonMap = w3cAnnotationCollection.getJsonMap(); String jsonStr = JsonUtils.toString(jsonMap); Object[] params = {collectionId, jsonStr}; int[] sqlTypes = {Types.VARCHAR, Types.OTHER}; when(jdbcTemplate.query(anyString(), aryEq(params), aryEq(sqlTypes), (W3CAnnotationCollectionRowMapper) any())).thenReturn(new ArrayList<W3CAnnotationCollection>() { { add(w3cAnnotationCollection); } }); W3CAnnotationCollection returnedW3CAnnotationCollection = annotationCollectionStoreRepository.createAnnotationCollection(collectionId, jsonStr); verify(jdbcTemplate, times(1)).query(anyString(), aryEq(params), aryEq(sqlTypes), (W3CAnnotationCollectionRowMapper) any()); assertThat(w3cAnnotationCollection, is(equalTo(returnedW3CAnnotationCollection))); }
Example 4
Source File: AnnotationStoreRepositoryJDBCImplTest.java From elucidate-server with MIT License | 6 votes |
@Test @SuppressWarnings("serial") public void testUpdateAnnotation() throws Exception { W3CAnnotation w3cAnnotation = generateRandomW3CAnnotation(); String collectionId = w3cAnnotation.getCollectionId(); String annotationId = w3cAnnotation.getAnnotationId(); Map<String, Object> jsonMap = w3cAnnotation.getJsonMap(); String jsonStr = JsonUtils.toString(jsonMap); Object[] params = {collectionId, annotationId, jsonStr, null}; int[] sqlTypes = {Types.VARCHAR, Types.VARCHAR, Types.OTHER, Types.INTEGER}; when(jdbcTemplate.query(anyString(), aryEq(params), aryEq(sqlTypes), (W3CAnnotationRowMapper) any())).thenReturn(new ArrayList<W3CAnnotation>() { { add(w3cAnnotation); } }); W3CAnnotation returnedW3CAnnotation = annotationStoreRepository.createAnnotation(collectionId, annotationId, jsonStr, null); verify(jdbcTemplate, times(1)).query(anyString(), aryEq(params), aryEq(sqlTypes), (W3CAnnotationRowMapper) any()); assertThat(w3cAnnotation, is(equalTo(returnedW3CAnnotation))); }
Example 5
Source File: Column.java From sql4es with Apache License 2.0 | 6 votes |
public Column(String columnName, Operation op) { this.columnName = columnName; this.op = op; if(columnName.equals("*") && op == Operation.COUNT) alias = "count(*)"; else if(columnName.equals("1") && op == Operation.COUNT) alias = "count(1)"; switch(this.op){ case COUNT: sqlType = Types.BIGINT; break; case NONE: sqlType = Types.VARCHAR; break; case MIN: sqlType = Types.DOUBLE; break; case MAX: sqlType = Types.DOUBLE; break; case SUM: sqlType = Types.DOUBLE; break; case AVG: sqlType = Types.DOUBLE; break; case HIGHLIGHT: sqlType = Types.ARRAY; break; case COUNT_DISTINCT: sqlType = Types.BIGINT; break; default: sqlType = Types.OTHER; } //if(calculation != null) sqlType = Types.DOUBLE; }
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: OracleCallMetaDataProvider.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public SqlParameter createDefaultOutParameter(String parameterName, CallParameterMetaData meta) { if (meta.getSqlType() == Types.OTHER && REF_CURSOR_NAME.equals(meta.getTypeName())) { return new SqlOutParameter(parameterName, getRefCursorSqlType(), new ColumnMapRowMapper()); } else { return super.createDefaultOutParameter(parameterName, meta); } }
Example 8
Source File: AnnotationAgentStoreRepositoryJDBCImpl.java From elucidate-server with MIT License | 5 votes |
@Override public AnnotationAgent createAnnotationGenerator(Integer annotationPK, Integer bodyPK, Integer targetPK, String generatorIri, String generatorJson, String[] types, String[] typesJson, String[] names, String[] namesJson, String nickname, String[] emails, String[] emailsJson, String[] emailSha1s, String[] emailSha1sJson, String[] homepages, String[] homepagesJson) { String sql = "SELECT * FROM annotation_generator_create(?, ?, ?, ?, ?, string_to_array(?, ','), string_to_array(?, ',')::jsonb[], string_to_array(?, ','), string_to_array(?, ',')::jsonb[], ?, string_to_array(?, ','), string_to_array(?, ',')::jsonb[], string_to_array(?, ','), string_to_array(?, ',')::jsonb[], string_to_array(?, ','), string_to_array(?, ',')::jsonb[])"; Object[] params = {annotationPK, bodyPK, targetPK, generatorIri, generatorJson, String.join(",", types), String.join(",", typesJson), String.join(",", names), String.join(",", namesJson), nickname, String.join(",", emails), String.join(",", emailsJson), String.join(",", emailSha1s), String.join(",", emailSha1sJson), String.join(",", homepages), String.join(",", homepagesJson)}; int[] sqlTypes = {Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.OTHER, Types.VARCHAR, Types.OTHER, Types.VARCHAR, Types.OTHER, Types.VARCHAR, Types.VARCHAR, Types.OTHER, Types.VARCHAR, Types.OTHER, Types.VARCHAR, Types.OTHER}; List<AnnotationAgent> annotationAgents = queryForObject(sql, params, sqlTypes, new AnnotationAgentResultSetExtractor()); if (annotationAgents.isEmpty()) { return null; } else if (annotationAgents.size() == 1) { return annotationAgents.get(0); } else { throw new IncorrectResultSizeDataAccessException(0, annotationAgents.size()); } }
Example 9
Source File: TypesTranslator.java From sql-layer with GNU Affero General Public License v3.0 | 5 votes |
public int jdbcType(TInstance type) { TClass tclass = TInstance.tClass(type); if (tclass == null) return Types.OTHER; else return tclass.jdbcType(); }
Example 10
Source File: CassandraPreparedStatement.java From cassandra-jdbc-wrapper with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "boxing", "unchecked" }) public final void setObject(int parameterIndex, Object object, int targetSqlType, int scaleOrLength) throws SQLException { checkNotClosed(); checkIndex(parameterIndex); switch(targetSqlType){ case Types.VARCHAR: this.statement.setString(parameterIndex-1, object.toString()); break; case Types.BIGINT: this.statement.setLong(parameterIndex-1, Long.parseLong(object.toString())); break; case Types.BINARY: byte[] array = new byte[((java.io.ByteArrayInputStream)object).available()]; try { ((java.io.ByteArrayInputStream)object).read(array); } catch (IOException e1) { LOG.warn("Exception while setting object of BINARY type", e1); } this.statement.setBytes(parameterIndex-1, (ByteBuffer.wrap((array)))); break; case Types.BOOLEAN: this.statement.setBool(parameterIndex-1, (Boolean)object); break; case Types.CHAR: this.statement.setString(parameterIndex-1, object.toString()); break; case Types.CLOB: this.statement.setString(parameterIndex-1, object.toString()); break; case Types.TIMESTAMP: this.statement.setTimestamp(parameterIndex-1, (Timestamp)object); break; case Types.DECIMAL: this.statement.setDecimal(parameterIndex-1, (BigDecimal)object); break; case Types.DOUBLE: this.statement.setDouble(parameterIndex-1, (Double)object); break; case Types.FLOAT: this.statement.setFloat(parameterIndex-1, (Float)object); break; case Types.INTEGER: try{ this.statement.setInt(parameterIndex-1, (Integer)object); }catch(CodecNotFoundException e){ if(e.getMessage().contains("varint")){ // sucks but works this.statement.setVarint(parameterIndex-1, BigInteger.valueOf(Long.parseLong(object.toString()))); } } break; case Types.DATE: this.statement.setTimestamp(parameterIndex-1, (Date)object); break; case Types.ROWID: this.statement.setUUID(parameterIndex-1, (java.util.UUID)object); break; case Types.OTHER: if(object.getClass().equals(com.datastax.driver.core.TupleValue.class)){ this.statement.setTupleValue(parameterIndex-1, (com.datastax.driver.core.TupleValue) object); } if(object.getClass().equals(java.util.UUID.class)){ this.statement.setUUID(parameterIndex-1, (java.util.UUID) object); } if(object.getClass().equals(java.net.InetAddress.class) || object.getClass().equals(java.net.Inet4Address.class)){ this.statement.setInet(parameterIndex-1, (InetAddress) object); } else if ( List.class.isAssignableFrom(object.getClass())) { this.statement.setList(parameterIndex-1,handleAsList(object.getClass(), object)); } else if ( Set.class.isAssignableFrom(object.getClass())) { this.statement.setSet(parameterIndex-1,handleAsSet(object.getClass(), object)); } else if ( Map.class.isAssignableFrom(object.getClass())) { this.statement.setMap(parameterIndex-1,handleAsMap(object.getClass(), object)); } break; } }
Example 11
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"; default: return null; } }
Example 12
Source File: PostgreSQLPeriodType.java From hibernate-types with Apache License 2.0 | 4 votes |
@Override public int[] sqlTypes() { return new int[]{Types.OTHER}; }
Example 13
Source File: Util.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public static String typeName(int jdbcType) { switch (jdbcType) { case Types.ARRAY: return TypeId.ARRAY_NAME; case Types.BIT : return TypeId.BIT_NAME; case Types.BOOLEAN : return TypeId.BOOLEAN_NAME; case Types.DATALINK: return TypeId.DATALINK_NAME; case Types.TINYINT : return TypeId.TINYINT_NAME; case Types.SMALLINT : return TypeId.SMALLINT_NAME; case Types.INTEGER : return TypeId.INTEGER_NAME; case Types.BIGINT : return TypeId.LONGINT_NAME; case Types.FLOAT : return TypeId.FLOAT_NAME; case Types.REAL : return TypeId.REAL_NAME; case Types.DOUBLE : return TypeId.DOUBLE_NAME; case Types.NUMERIC : return TypeId.NUMERIC_NAME; case Types.DECIMAL : return TypeId.DECIMAL_NAME; case Types.CHAR : return TypeId.CHAR_NAME; case Types.VARCHAR : return TypeId.VARCHAR_NAME; case Types.LONGVARCHAR : return "LONGVARCHAR"; case Types.CLOB : return TypeId.CLOB_NAME; case Types.DATE : return TypeId.DATE_NAME; case Types.TIME : return TypeId.TIME_NAME; case Types.TIMESTAMP : return TypeId.TIMESTAMP_NAME; case Types.BINARY : return TypeId.BINARY_NAME; case Types.VARBINARY : return TypeId.VARBINARY_NAME; case Types.LONGVARBINARY : return TypeId.LONGVARBINARY_NAME; case Types.BLOB : return TypeId.BLOB_NAME; case Types.OTHER : return "OTHER"; case Types.JAVA_OBJECT : return "Types.JAVA_OBJECT"; case Types.REF : return TypeId.REF_NAME; case JDBC40Translation.ROWID: return TypeId.ROWID_NAME; case Types.STRUCT: return TypeId.STRUCT_NAME; case StoredFormatIds.XML_TYPE_ID : return TypeId.XML_NAME; case JDBC40Translation.SQLXML: return TypeId.SQLXML_NAME; case JDBC40Translation.JSON: return TypeId.JSON_NAME; default : return String.valueOf(jdbcType); } }
Example 14
Source File: PostgresCallMetaDataProvider.java From java-technology-stack with MIT License | 4 votes |
@Override public int getRefCursorSqlType() { return Types.OTHER; }
Example 15
Source File: JdbcTuple.java From cassandra-jdbc-wrapper with Apache License 2.0 | 4 votes |
public int getJdbcType() { return Types.OTHER; }
Example 16
Source File: SimpleStringOperatorNode.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Bind this operator * * @param fromList The query's FROM list * @param subqueryList The subquery list being built as we find SubqueryNodes * @param aggregateVector The aggregate vector being built as we find AggregateNodes * * @return The new top of the expression tree. * * @exception StandardException Thrown on error */ public ValueNode bindExpression( FromList fromList, SubqueryList subqueryList, Vector aggregateVector) throws StandardException { TypeId operandType; bindOperand(fromList, subqueryList, aggregateVector); /* ** Check the type of the operand - this function is allowed only on ** string value (char and bit) types. */ operandType = operand.getTypeId(); switch (operandType.getJDBCTypeId()) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: case Types.CLOB: break; case Types.JAVA_OBJECT: case Types.OTHER: { throw StandardException.newException(SQLState.LANG_UNARY_FUNCTION_BAD_TYPE, methodName, operandType.getSQLTypeName()); } default: DataTypeDescriptor dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, true, operand.getTypeCompiler(). getCastToCharWidth( operand.getTypeServices())); operand = (ValueNode) getNodeFactory().getNode( C_NodeTypes.CAST_NODE, operand, dtd, getContextManager()); // DERBY-2910 - Match current schema collation for implicit cast as we do for // explicit casts per SQL Spec 6.12 (10) operand.setCollationUsingCompilationSchema(); ((CastNode) operand).bindCastNodeOnly(); operandType = operand.getTypeId(); } /* ** The result type of upper()/lower() is the type of the operand. */ setType(new DataTypeDescriptor(operandType, operand.getTypeServices().isNullable(), operand.getTypeCompiler(). getCastToCharWidth(operand.getTypeServices()) ) ); //Result of upper()/lower() will have the same collation as the //argument to upper()/lower(). setCollationInfo(operand.getTypeServices()); return this; }
Example 17
Source File: ResultSetTableModel.java From netbeans with Apache License 2.0 | 4 votes |
protected static Class<? extends Object> getTypeClass(DBColumn col) { int colType = col.getJdbcType(); if (colType == Types.BIT && col.getPrecision() <= 1) { colType = Types.BOOLEAN; } switch (colType) { case Types.BOOLEAN: return Boolean.class; case Types.TIME: return Time.class; case Types.DATE: return Date.class; case Types.TIMESTAMP: case DBReadWriteHelper.SQL_TYPE_ORACLE_TIMESTAMP: case DBReadWriteHelper.SQL_TYPE_ORACLE_TIMESTAMP_WITH_TZ: return Timestamp.class; case Types.BIGINT: return BigInteger.class; case Types.DOUBLE: return Double.class; case Types.FLOAT: case Types.REAL: return Float.class; case Types.DECIMAL: case Types.NUMERIC: return BigDecimal.class; case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: return Long.class; case Types.CHAR: case Types.VARCHAR: case Types.NCHAR: case Types.NVARCHAR: case Types.ROWID: return String.class; case Types.BIT: case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: case Types.BLOB: return Blob.class; case Types.LONGVARCHAR: case Types.LONGNVARCHAR: case Types.CLOB: case Types.NCLOB: /*NCLOB */ return Clob.class; case Types.OTHER: default: return Object.class; } }
Example 18
Source File: StatementCreatorUtils.java From spring-analysis-note with MIT License | 4 votes |
/** * Set the specified PreparedStatement parameter to null, * respecting database-specific peculiarities. */ private static void setNull(PreparedStatement ps, int paramIndex, int sqlType, @Nullable String typeName) throws SQLException { if (sqlType == SqlTypeValue.TYPE_UNKNOWN || (sqlType == Types.OTHER && typeName == null)) { boolean useSetObject = false; Integer sqlTypeToUse = null; if (!shouldIgnoreGetParameterType) { try { sqlTypeToUse = ps.getParameterMetaData().getParameterType(paramIndex); } catch (SQLException ex) { if (logger.isDebugEnabled()) { logger.debug("JDBC getParameterType call failed - using fallback method instead: " + ex); } } } if (sqlTypeToUse == null) { // Proceed with database-specific checks sqlTypeToUse = Types.NULL; DatabaseMetaData dbmd = ps.getConnection().getMetaData(); String jdbcDriverName = dbmd.getDriverName(); String databaseProductName = dbmd.getDatabaseProductName(); if (databaseProductName.startsWith("Informix") || (jdbcDriverName.startsWith("Microsoft") && jdbcDriverName.contains("SQL Server"))) { // "Microsoft SQL Server JDBC Driver 3.0" versus "Microsoft JDBC Driver 4.0 for SQL Server" useSetObject = true; } else if (databaseProductName.startsWith("DB2") || jdbcDriverName.startsWith("jConnect") || jdbcDriverName.startsWith("SQLServer")|| jdbcDriverName.startsWith("Apache Derby")) { sqlTypeToUse = Types.VARCHAR; } } if (useSetObject) { ps.setObject(paramIndex, null); } else { ps.setNull(paramIndex, sqlTypeToUse); } } else if (typeName != null) { ps.setNull(paramIndex, sqlType, typeName); } else { ps.setNull(paramIndex, sqlType); } }
Example 19
Source File: PostgreSQLCITextType.java From hibernate-types with Apache License 2.0 | 4 votes |
@Override public int[] sqlTypes() { return new int[]{Types.OTHER}; }
Example 20
Source File: PostgreSQLInetType.java From hibernate-types with Apache License 2.0 | 4 votes |
@Override public int[] sqlTypes() { return new int[]{Types.OTHER}; }