Example usage for java.sql Clob setAsciiStream

List of usage examples for java.sql Clob setAsciiStream

Introduction

In this page you can find the example usage for java.sql Clob setAsciiStream.

Prototype

java.io.OutputStream setAsciiStream(long pos) throws SQLException;

Source Link

Document

Retrieves a stream to be used to write Ascii characters to the CLOB value that this Clob object represents, starting at position pos .

Usage

From source file:nl.nn.adapterframework.util.JdbcUtil.java

/**
 * retrieves an outputstream to a clob column from an updatable resultset.
 */// w  w  w.j  a  v a 2  s .  c o  m
public static OutputStream getClobUpdateOutputStreamxxx(ResultSet rs, int columnIndex)
        throws SQLException, JdbcException {
    Clob clob = rs.getClob(columnIndex);
    if (clob == null) {
        throw new JdbcException("no clob found in column [" + columnIndex + "]");
    }
    return clob.setAsciiStream(1L);
}

From source file:org.springframework.jdbc.support.lob.TemporaryLobCreator.java

@Override
public void setClobAsAsciiStream(PreparedStatement ps, int paramIndex, @Nullable InputStream asciiStream,
        int contentLength) throws SQLException {

    if (asciiStream != null) {
        Clob clob = ps.getConnection().createClob();
        try {/*w  w  w .j av a2s  .c  o  m*/
            FileCopyUtils.copy(asciiStream, clob.setAsciiStream(1));
        } catch (IOException ex) {
            throw new DataAccessResourceFailureException("Could not copy into LOB stream", ex);
        }
        this.temporaryClobs.add(clob);
        ps.setClob(paramIndex, clob);
    } else {
        ps.setClob(paramIndex, (Clob) null);
    }

    if (logger.isDebugEnabled()) {
        logger.debug(
                asciiStream != null ? "Copied ASCII stream into temporary CLOB with length " + contentLength
                        : "Set CLOB to null");
    }
}