try { java.sql.Clob clob = oracle.sql.CLOB.createTemporary( connection, false, oracle.sql.CLOB.DURATION_SESSION); clob.setString(1, xml); stmt.setClob(position, clob); stmt.execute(); } // Important! finally { clob.free(); }
@Override public void setClobAsString(PreparedStatement ps, int paramIndex, String content) throws SQLException { Clob clob = ps.getConnection().createClob(); clob.setString(1, content); ps.setClob(paramIndex, clob); }
@Override public void setClobAsString(PreparedStatement ps, int paramIndex, @Nullable String content) throws SQLException { if (content != null) { Clob clob = ps.getConnection().createClob(); clob.setString(1, content); this.temporaryClobs.add(clob); ps.setClob(paramIndex, clob); } else { ps.setClob(paramIndex, (Clob) null); } if (logger.isDebugEnabled()) { logger.debug(content != null ? "Copied string into temporary CLOB with length " + content.length() : "Set CLOB to null"); } }
@Override public Clob createClob(String string) { try { final Clob clob = createClob(); clob.setString( 1, string ); return clob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set CLOB string after creation", e ); } }
@Override public int clob_setString(ClobProxy clob, long pos, String str, int offset, int len) throws SQLException { if (this.pos < filterSize) { return nextFilter().clob_setString(this, clob, pos, str, offset, len); } return clob.getRawClob().setString(pos, str, offset, len); }
@Override public int clob_setString(ClobProxy clob, long pos, String str) throws SQLException { if (this.pos < filterSize) { return nextFilter().clob_setString(this, clob, pos, str); } return clob.getRawClob().setString(pos, str); }
@Override public void setClobAsString(PreparedStatement ps, int paramIndex, String content) throws SQLException { Clob clob = ps.getConnection().createClob(); clob.setString(1, content); ps.setClob(paramIndex, clob); }
@Override public int clob_setString(ClobProxy clob, long pos, String str, int offset, int len) throws SQLException { if (this.pos < filterSize) { return nextFilter().clob_setString(this, clob, pos, str, offset, len); } return clob.getRawClob().setString(pos, str, offset, len); }
@Override public int clob_setString(ClobProxy clob, long pos, String str) throws SQLException { if (this.pos < filterSize) { return nextFilter().clob_setString(this, clob, pos, str); } return clob.getRawClob().setString(pos, str); }
@Override public Integer call() throws SQLException { return clob.setString(pos, str); } });
@Override public Integer call() throws SQLException { return clob.setString(pos, str, offset, len); } });
/** * {@inheritDoc} */ @Override public int setString(long pos, String str) throws SQLException { return this.clob.setString(pos, str); }
/** * {@inheritDoc} */ @Override public int setString(long pos, String str, int offset, int len) throws SQLException { return this.clob.setString(pos, str, offset, len); }
/** * @see java.sql.Clob#setString(long, java.lang.String, int, int) */ public int setString(long pos, String str, int offset, int len) throws SQLException { return this.reference.setString(pos, str, offset, len); }
/** * Invoke the JDK 1.4 <code>setString</code> method on the given CLOB * object. */ public void putString(Clob clob, String data) throws SQLException { clob.setString(1L, data); }
/** * {@inheritDoc} */ @Override public int setString(long pos, String str) throws SQLException { return this.clob.setString(pos, str); }
@Override public Clob createTemporaryClob(Connection connection, byte[] bytes) throws Exception { Clob clob = connection.createClob(); clob.setString(1, new String(bytes)); return clob; }
Connection con = null;// write code to make a connection object Clob clob = con.createClob(); String str = "this is a stirng"; clob.setString(0, str ); PreparedStatement ps = null;// write code to create a prepared statement ps.setClob(4, clob);
@Override public CallableStatement createCallableStatement(Connection con) throws SQLException { CallableStatement cs = con.prepareCall("{CALL ConsultaFuncionarios.fncConsultaFuncionarios(?)}"); cs.registerOutParameter(1, Types.CLOB); Connection conn = jdbcExtractor.getNativeConnection(con); Clob clob = conn.createClob(); clob.setString(1, xml); cs.setClob(1, clob); return cs; } }, new CallableStatementCallback<String>() {
@Test public void convertsInputStreamToClob() throws Exception { String streamContent = "bar"; InputStream value = new StringInputStream(streamContent); dataType.setParameterValue(statement, PARAM_INDEX, value); verify(clob).setString(1, streamContent); verify(statement).setObject(PARAM_INDEX, clob, CLOB); }