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

public Class SqlCharacterValue

extends Object
implements SqlTypeValue
Class Inheritance
All Implemented Interfaces
org.springframework.jdbc.core.SqlTypeValue
Imports
java.io.CharArrayReader, .InputStream, .Reader, .StringReader, java.sql.PreparedStatement, .SQLException, .Types, org.springframework.jdbc.core.SqlTypeValue, org.springframework.lang.Nullable

Object to represent a character-based parameter value for a SQL statement, e.g. a character stream for a CLOB/NCLOB or a LONGVARCHAR column.

Designed for use with org.springframework.jdbc.core.JdbcTemplate as well as org.springframework.jdbc.core.simple.JdbcClient, to be passed in as a parameter value wrapping the target content value. Can be combined with org.springframework.jdbc.core.SqlParameterValue for specifying a SQL type, e.g. new SqlParameterValue(Types.CLOB, new SqlCharacterValue(myContent)). With most database drivers, the type hint is not actually necessary.

Author
Juergen Hoeller
Since
6.1.4
See Also
SqlBinaryValue, org.springframework.jdbc.core.SqlParameterValue

Field Summary

Modifier and TypeField and Description
private final Object
private final long

Constructor Summary

AccessConstructor and Description
public
SqlCharacterValue(CharSequence
the content as a String or other CharSequence
string
)

Create a new CLOB value with the given content string.

public
SqlCharacterValue(char[]
the content as a character array
characters
)

Create a new SqlCharacterValue for the given content.

public
SqlCharacterValue(Reader
the content reader
reader
,
long
the length of the content
length
)

Create a new SqlCharacterValue for the given content.

public
SqlCharacterValue(InputStream
the content as ASCII stream
asciiStream
,
long
the length of the content
length
)

Create a new SqlCharacterValue for the given content.

Method Summary

Modifier and TypeMethod and Description
private void
setReader(PreparedStatement ps, int paramIndex, int sqlType, Reader reader, long length)

private void
setString(PreparedStatement ps, int paramIndex, int sqlType, String string)

public void
setTypeValue(PreparedStatement
the PreparedStatement to work on
ps
,
int
the index of the parameter for which we need to set the value
paramIndex
,
int
the SQL type of the parameter we are setting
sqlType
,
String
the type name of the parameter (optional)
typeName
)

Implements org.springframework.jdbc.core.SqlTypeValue.setTypeValue.

Set the type value on the given PreparedStatement.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentback to summary
private final Object content
lengthback to summary
private final long length

Constructor Detail

SqlCharacterValueback to summary
public SqlCharacterValue(CharSequence string)

Create a new CLOB value with the given content string.

Parameters
string:CharSequence

the content as a String or other CharSequence

SqlCharacterValueback to summary
public SqlCharacterValue(char[] characters)

Create a new SqlCharacterValue for the given content.

Parameters
characters:char[]

the content as a character array

SqlCharacterValueback to summary
public SqlCharacterValue(Reader reader, long length)

Create a new SqlCharacterValue for the given content.

Parameters
reader:Reader

the content reader

length:long

the length of the content

SqlCharacterValueback to summary
public SqlCharacterValue(InputStream asciiStream, long length)

Create a new SqlCharacterValue for the given content.

Parameters
asciiStream:InputStream

the content as ASCII stream

length:long

the length of the content

Method Detail

setReaderback to summary
private void setReader(PreparedStatement ps, int paramIndex, int sqlType, Reader reader, long length) throws SQLException
setStringback to summary
private void setString(PreparedStatement ps, int paramIndex, int sqlType, String string) throws SQLException
setTypeValueback to summary
public void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName) throws SQLException

Implements org.springframework.jdbc.core.SqlTypeValue.setTypeValue.

Doc from org.springframework.jdbc.core.SqlTypeValue.setTypeValue.

Set the type value on the given PreparedStatement.

Parameters
ps:PreparedStatement

the PreparedStatement to work on

paramIndex:int

the index of the parameter for which we need to set the value

sqlType:int

the SQL type of the parameter we are setting

typeName:String

the type name of the parameter (optional)

Annotations
@Override
Exceptions
SQLException:
if an SQLException is encountered while setting parameter values