Top Description Fields Constructors Methods
org.springframework.jdbc.support.lob

public Class TemporaryLobCreator

extends Object
implements LobCreator
Class Inheritance
All Implemented Interfaces
org.springframework.jdbc.support.lob.LobCreator, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.IOException, .InputStream, .Reader, java.sql.Blob, .Clob, .PreparedStatement, .SQLException, java.util.LinkedHashSet, .Set, org.apache.commons.logging.Log, .LogFactory, org.springframework.dao.DataAccessResourceFailureException, org.springframework.lang.Nullable, org.springframework.util.FileCopyUtils

LobCreator implementation based on temporary LOBs, using JDBC's java.sql.Connection#createBlob() / java.sql.Connection#createClob() mechanism.

Used by DefaultLobHandler's DefaultLobHandler#setCreateTemporaryLob mode. Can also be used directly to reuse the tracking and freeing of temporary LOBs.

Author
Juergen Hoeller
Since
3.2.2
See Also
DefaultLobHandler#setCreateTemporaryLob, java.sql.Connection#createBlob(), java.sql.Connection#createClob()

Field Summary

Modifier and TypeField and Description
protected static final Log
private final Set<Blob>
private final Set<Clob>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements org.springframework.jdbc.support.lob.LobCreator.close.

Close this LobCreator session and free its temporarily created BLOBs and CLOBs.

public void
setBlobAsBinaryStream(PreparedStatement
the PreparedStatement to the set the content on
ps
,
int
the parameter index to use
paramIndex
,
InputStream
the content as binary stream, or null for SQL NULL
binaryStream
,
int contentLength)

Implements org.springframework.jdbc.support.lob.LobCreator.setBlobAsBinaryStream.

Set the given content as binary stream on the given statement, using the given parameter index.

public void
setBlobAsBytes(PreparedStatement
the PreparedStatement to the set the content on
ps
,
int
the parameter index to use
paramIndex
,
byte[]
the content as byte array, or null for SQL NULL
content
)

Implements org.springframework.jdbc.support.lob.LobCreator.setBlobAsBytes.

Set the given content as bytes on the given statement, using the given parameter index.

public void
setClobAsAsciiStream(PreparedStatement
the PreparedStatement to the set the content on
ps
,
int
the parameter index to use
paramIndex
,
InputStream
the content as ASCII stream, or null for SQL NULL
asciiStream
,
int contentLength)

Implements org.springframework.jdbc.support.lob.LobCreator.setClobAsAsciiStream.

Set the given content as ASCII stream on the given statement, using the given parameter index.

public void
setClobAsCharacterStream(PreparedStatement
the PreparedStatement to the set the content on
ps
,
int
the parameter index to use
paramIndex
,
Reader
the content as character stream, or null for SQL NULL
characterStream
,
int contentLength)

Implements org.springframework.jdbc.support.lob.LobCreator.setClobAsCharacterStream.

Set the given content as character stream on the given statement, using the given parameter index.

public void
setClobAsString(PreparedStatement
the PreparedStatement to the set the content on
ps
,
int
the parameter index to use
paramIndex
,
String
the content as String, or null for SQL NULL
content
)

Implements org.springframework.jdbc.support.lob.LobCreator.setClobAsString.

Set the given content as String on the given statement, using the given parameter index.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
protected static final Log logger
temporaryBlobsback to summary
private final Set<Blob> temporaryBlobs
temporaryClobsback to summary
private final Set<Clob> temporaryClobs

Constructor Detail

TemporaryLobCreatorback to summary
public TemporaryLobCreator()

Method Detail

closeback to summary
public void close()

Implements org.springframework.jdbc.support.lob.LobCreator.close.

Doc from org.springframework.jdbc.support.lob.LobCreator.close.

Close this LobCreator session and free its temporarily created BLOBs and CLOBs. Will not need to do anything if using PreparedStatement's standard methods, but might be necessary to free database resources if using proprietary means.

Note

Needs to be invoked after the involved PreparedStatements have been executed or the affected O/R mapping sessions have been flushed. Otherwise, the database resources for the temporary BLOBs might stay allocated.

Annotations
@Override
setBlobAsBinaryStreamback to summary
public void setBlobAsBinaryStream(PreparedStatement ps, int paramIndex, InputStream binaryStream, int contentLength) throws SQLException

Implements org.springframework.jdbc.support.lob.LobCreator.setBlobAsBinaryStream.

Doc from org.springframework.jdbc.support.lob.LobCreator.setBlobAsBinaryStream.

Set the given content as binary stream on the given statement, using the given parameter index. Might simply invoke PreparedStatement.setBinaryStream or create a Blob instance for it, depending on the database and driver.

Parameters
ps:PreparedStatement

the PreparedStatement to the set the content on

paramIndex:int

the parameter index to use

binaryStream:InputStream

the content as binary stream, or null for SQL NULL

Annotations
@Override
Exceptions
SQLException:
if thrown by JDBC methods
setBlobAsBytesback to summary
public void setBlobAsBytes(PreparedStatement ps, int paramIndex, byte[] content) throws SQLException

Implements org.springframework.jdbc.support.lob.LobCreator.setBlobAsBytes.

Doc from org.springframework.jdbc.support.lob.LobCreator.setBlobAsBytes.

Set the given content as bytes on the given statement, using the given parameter index. Might simply invoke PreparedStatement.setBytes or create a Blob instance for it, depending on the database and driver.

Parameters
ps:PreparedStatement

the PreparedStatement to the set the content on

paramIndex:int

the parameter index to use

content:byte[]

the content as byte array, or null for SQL NULL

Annotations
@Override
Exceptions
SQLException:
if thrown by JDBC methods
setClobAsAsciiStreamback to summary
public void setClobAsAsciiStream(PreparedStatement ps, int paramIndex, InputStream asciiStream, int contentLength) throws SQLException

Implements org.springframework.jdbc.support.lob.LobCreator.setClobAsAsciiStream.

Doc from org.springframework.jdbc.support.lob.LobCreator.setClobAsAsciiStream.

Set the given content as ASCII stream on the given statement, using the given parameter index. Might simply invoke PreparedStatement.setAsciiStream or create a Clob instance for it, depending on the database and driver.

Parameters
ps:PreparedStatement

the PreparedStatement to the set the content on

paramIndex:int

the parameter index to use

asciiStream:InputStream

the content as ASCII stream, or null for SQL NULL

Annotations
@Override
Exceptions
SQLException:
if thrown by JDBC methods
setClobAsCharacterStreamback to summary
public void setClobAsCharacterStream(PreparedStatement ps, int paramIndex, Reader characterStream, int contentLength) throws SQLException

Implements org.springframework.jdbc.support.lob.LobCreator.setClobAsCharacterStream.

Doc from org.springframework.jdbc.support.lob.LobCreator.setClobAsCharacterStream.

Set the given content as character stream on the given statement, using the given parameter index. Might simply invoke PreparedStatement.setCharacterStream or create a Clob instance for it, depending on the database and driver.

Parameters
ps:PreparedStatement

the PreparedStatement to the set the content on

paramIndex:int

the parameter index to use

characterStream:Reader

the content as character stream, or null for SQL NULL

Annotations
@Override
Exceptions
SQLException:
if thrown by JDBC methods
setClobAsStringback to summary
public void setClobAsString(PreparedStatement ps, int paramIndex, String content) throws SQLException

Implements org.springframework.jdbc.support.lob.LobCreator.setClobAsString.

Doc from org.springframework.jdbc.support.lob.LobCreator.setClobAsString.

Set the given content as String on the given statement, using the given parameter index. Might simply invoke PreparedStatement.setString or create a Clob instance for it, depending on the database and driver.

Parameters
ps:PreparedStatement

the PreparedStatement to the set the content on

paramIndex:int

the parameter index to use

content:String

the content as String, or null for SQL NULL

Annotations
@Override
Exceptions
SQLException:
if thrown by JDBC methods