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,
for example, 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, for example,
new SqlParameterValue(Types.CLOB, new SqlCharacterValue(myContent)).
With most database drivers, the type hint is not actually necessary.
Note: Only specify Types.CLOB in case of an actual CLOB, preferring
Types.LONGVARCHAR otherwise. This is in contrast to SqlLobValue
where char sequence handling was lenient.
- Since:
- 6.1.4
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from interface SqlTypeValue
TYPE_UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionSqlCharacterValue(char[] characters) Create a newSqlCharacterValuefor the given content.SqlCharacterValue(InputStream asciiStream, long length) Create a newSqlCharacterValuefor the given content.SqlCharacterValue(Reader reader, long length) Create a newSqlCharacterValuefor the given content.SqlCharacterValue(CharSequence string) Create a new CLOB value with the given content string. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetTypeValue(PreparedStatement ps, int paramIndex, int sqlType, @Nullable 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 newSqlCharacterValuefor the given content.- Parameters:
characters- the content as a character array
-
SqlCharacterValue
Create a newSqlCharacterValuefor the given content.- Parameters:
reader- the content readerlength- the length of the content
-
SqlCharacterValue
Create a newSqlCharacterValuefor 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:SqlTypeValueSet the type value on the given PreparedStatement.- Specified by:
setTypeValuein 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:
-