Class SqlCharacterValue
java.lang.Object
org.springframework.jdbc.core.support.SqlCharacterValue
- All Implemented Interfaces:
SqlTypeValue
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 JdbcTemplate
as well as JdbcClient
, to be
passed in as a parameter value wrapping the target content value. Can be
combined with 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.
- Since:
- 6.1.4
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.jdbc.core.SqlTypeValue
TYPE_UNKNOWN
-
Constructor Summary
ConstructorDescriptionSqlCharacterValue
(char[] characters) Create a newSqlCharacterValue
for the given content.SqlCharacterValue
(InputStream asciiStream, long length) Create a newSqlCharacterValue
for the given content.SqlCharacterValue
(Reader reader, long length) Create a newSqlCharacterValue
for the given content.SqlCharacterValue
(CharSequence string) Create a new CLOB value with the given content string. -
Method Summary
Modifier and TypeMethodDescriptionvoid
setTypeValue
(PreparedStatement ps, int paramIndex, int sqlType, String typeName) Set the type value on the given PreparedStatement.
-
Constructor Details
-
SqlCharacterValue
Create a new CLOB value with the given content string.- Parameters:
string
- the content as a String or other CharSequence
-
SqlCharacterValue
public SqlCharacterValue(char[] characters) Create a newSqlCharacterValue
for the given content.- Parameters:
characters
- the content as a character array
-
SqlCharacterValue
Create a newSqlCharacterValue
for the given content.- Parameters:
reader
- the content readerlength
- the length of the content
-
SqlCharacterValue
Create a newSqlCharacterValue
for the given content.- Parameters:
asciiStream
- the content as ASCII streamlength
- the length of the content
-
-
Method Details
-
setTypeValue
public void setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, @Nullable String typeName) throws SQLException Description copied from interface:SqlTypeValue
Set the type value on the given PreparedStatement.- Specified by:
setTypeValue
in interfaceSqlTypeValue
- Parameters:
ps
- the PreparedStatement to work onparamIndex
- the index of the parameter for which we need to set the valuesqlType
- the SQL type of the parameter we are settingtypeName
- the type name of the parameter (optional)- Throws:
SQLException
- if an SQLException is encountered while setting parameter values- See Also:
-