private static ConcurrentHashMap<Class, Integer> buildJdbcJavaClassMappings() { ConcurrentHashMap<Class, Integer> jdbcJavaClassMappings = new ConcurrentHashMap<Class, Integer>(); // these mappings are the ones outlined specifically in the spec jdbcJavaClassMappings.put( String.class, Types.VARCHAR ); jdbcJavaClassMappings.put( BigDecimal.class, Types.NUMERIC ); jdbcJavaClassMappings.put( Boolean.class, Types.BIT ); jdbcJavaClassMappings.put( Integer.class, Types.INTEGER ); jdbcJavaClassMappings.put( Long.class, Types.BIGINT ); jdbcJavaClassMappings.put( Float.class, Types.REAL ); jdbcJavaClassMappings.put( Double.class, Types.DOUBLE ); jdbcJavaClassMappings.put( byte[].class, Types.LONGVARBINARY ); jdbcJavaClassMappings.put( java.sql.Date.class, Types.DATE ); jdbcJavaClassMappings.put( Time.class, Types.TIME ); jdbcJavaClassMappings.put( Timestamp.class, Types.TIMESTAMP ); jdbcJavaClassMappings.put( Blob.class, Types.BLOB ); jdbcJavaClassMappings.put( Clob.class, Types.CLOB ); jdbcJavaClassMappings.put( Array.class, Types.ARRAY ); jdbcJavaClassMappings.put( Struct.class, Types.STRUCT ); jdbcJavaClassMappings.put( Ref.class, Types.REF ); jdbcJavaClassMappings.put( Class.class, Types.JAVA_OBJECT ); // additional "common sense" registrations jdbcJavaClassMappings.put( Character.class, Types.CHAR ); jdbcJavaClassMappings.put( char[].class, Types.VARCHAR ); jdbcJavaClassMappings.put( Character[].class, Types.VARCHAR ); jdbcJavaClassMappings.put( Byte[].class, Types.LONGVARBINARY ); jdbcJavaClassMappings.put( java.util.Date.class, Types.TIMESTAMP ); jdbcJavaClassMappings.put( Calendar.class, Types.TIMESTAMP ); return jdbcJavaClassMappings; }
@Test(enabled = true) public void test09() throws Exception { Ref ref = new StubRef(sqlType, hero); Object[] values = {ref}; SQLInputImpl sqli = new SQLInputImpl(values, map); Ref ref2 = sqli.readRef(); assertTrue(ref.getObject().equals(ref2.getObject())); assertTrue(ref.getBaseTypeName().equals(ref2.getBaseTypeName())); }
public void setRef(int parameterIndex, Ref x) throws SQLException { try { if (this.wrappedStmt != null) { ((PreparedStatement) this.wrappedStmt).setRef(parameterIndex, x); } else { throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor); } } catch (SQLException sqlEx) { checkAndFireConnectionError(sqlEx); } }
/** * @see java.sql.CallableStatement#getRef(java.lang.String) */ public Ref getRef(String parameterName) throws SQLException { synchronized (checkClosed().getConnectionMutex()) { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be from ?= Ref retValue = rs.getRef(fixParameterName(parameterName)); this.outputParamWasNull = rs.wasNull(); return retValue; } }
protected void createDataTypesRows(RowSet crs) throws SQLException { Integer aInteger = 100; String aChar = "Oswald Cobblepot"; Long aLong = Long.MAX_VALUE; Short aShort = Short.MAX_VALUE; Double aDouble = Double.MAX_VALUE; BigDecimal aBigDecimal = BigDecimal.ONE; Boolean aBoolean = false; Float aFloat = Float.MAX_VALUE; Byte aByte = Byte.MAX_VALUE; Date aDate = Date.valueOf(LocalDate.now()); Time aTime = Time.valueOf(LocalTime.now()); Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now()); Array aArray = new StubArray("INTEGER", new Object[1]); Ref aRef = new SerialRef(new StubRef("INTEGER", query)); byte[] bytes = new byte[10]; crs.moveToInsertRow(); crs.updateInt(1, aInteger); crs.updateString(2, aChar); crs.updateString(3, aChar); crs.updateLong(4, aLong); crs.updateBoolean(5, aBoolean); crs.updateShort(6, aShort); crs.updateDouble(7, aDouble); crs.updateBigDecimal(8, aBigDecimal); crs.updateFloat(9, aFloat); crs.updateByte(10, aByte); crs.updateDate(11, aDate); crs.updateTime(12, aTime); crs.updateTimestamp(13, aTimeStamp); crs.updateBytes(14, bytes); crs.updateArray(15, aArray); crs.updateRef(16, aRef); crs.updateDouble(17, aDouble); crs.insertRow(); crs.moveToCurrentRow(); }
public Ref getRef(String parameterName) throws SQLException { try { if (this.wrappedStmt != null) { return ((CallableStatement) this.wrappedStmt).getRef(parameterName); } throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor); } catch (SQLException sqlEx) { checkAndFireConnectionError(sqlEx); } return null; }
@Override public Ref getRef(int columnIndex) throws SQLException { throw new SQLFeatureNotSupportedException(); }
@Override public Ref getRef( int columnIndex ) throws SQLException { throwIfClosed(); return super.getRef( columnIndex ); }
@Override public void updateRef(int columnIndex, Ref x) throws SQLException { throw new SQLFeatureNotSupportedException(); }
@Override public void setRef(int i, Ref x) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
@Override public void setRef(int parameterIndex, Ref x) throws SQLException { parameters.setParameter(parameterIndex, x); }
@Override public Ref getRef(String columnLabel) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
@Override public Ref getRef(int parameterIndex) throws SQLException { return wrappedStatement.getRef( parameterIndex ); }
@Override public Ref getRef(int columnIndex) throws SQLException { return null; }
@Override public void updateRef(int columnIndex, Ref x) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
public void setRef(int parameterIndex, Ref x) throws SQLException{ setObject(parameterIndex, x, Types.REF); }
@Override public Ref getRef(int columnIndex) throws SQLException { checkColumnBounds(columnIndex); throw SQLError.noSupport(); }
@Override public Ref getRef(String columnLabel) throws SQLException { return getRef(findColumn(columnLabel)); }
@Override public void updateRef(String columnLabel, Ref x) throws SQLException { throw SQLError.noSupport(); }
@Override public Ref getRef(String parameterName) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
@Override public Ref getRef() throws SQLException { throw new SQLFeatureNotSupportedException(); }
@Override default void updateRef(String columnLabel, Ref x) throws SQLException { }
@Override public void updateRef( String columnLabel, Ref x ) throws SQLException { checkNotClosed(); super.updateRef( columnLabel, x ); }
@Override public void setRef(int parameterIndex, Ref x) throws SQLException { pstmt.setRef(parameterIndex, x); }
@Override public Ref getRef(int parameterIndex) throws SQLException { return stmt.getRef(parameterIndex); }
@Override public Ref getRef(String parameterName) throws SQLException { return stmt.getRef(parameterName); }
@Override public Ref getRef(int columnIndex) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
@Override public Ref getRef(String columnLabel) throws SQLException { return null; }
@Override public Ref getRef(int parameterIndex) throws SQLException { // TODO Auto-generated method stub return null; }
@Override public void updateRef(String columnLabel, Ref x) throws SQLException { wrappedResultSet.updateRef( columnLabel, x ); }
public Ref getRef(int parameterIndex) throws SQLException { return this.bindingsAsRs.getRef(parameterIndex); }
/** * @see ResultSetInternalMethods#updateRef(String, Ref) */ public void updateRef(String arg0, Ref arg1) throws SQLException { throw SQLError.createSQLFeatureNotSupportedException(); }
@Override public void updateRef(String columnLabel, Ref x) throws SQLException { // TODO Auto-generated method stub }