Package org.springframework.jdbc.core.support

# Class SqlCharacterValue

java.lang.Object
org.springframework.jdbc.core.support.SqlCharacterValue

All Implemented Interfaces:
  `SqlTypeValue`

public class SqlCharacterValue extends Object implements 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.

Since:
  6.1.4
Author:
  Juergen Hoeller
See Also:
  - `SqlBinaryValue`
  - `SqlParameterValue`

## Field Summary

### Fields inherited from interface org.springframework.jdbc.core.SqlTypeValue

`TYPE_UNKNOWN`

## Constructor Summary

Constructors
Constructor
Description
`SqlCharacterValue(char[] characters)`
Create a new `SqlCharacterValue` for the given content.
`SqlCharacterValue(InputStream asciiStream, long length)`
Create a new `SqlCharacterValue` for the given content.
`SqlCharacterValue(Reader reader, long length)`
Create a new `SqlCharacterValue` for the given content.
`SqlCharacterValue(CharSequence string)`
Create a new CLOB value with the given content string.

## Method Summary

Modifier and Type
Method
Description
`void`
`setTypeValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName)`
Set the type value on the given PreparedStatement.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SqlCharacterValue

public SqlCharacterValue(CharSequence string)
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 new `SqlCharacterValue` for the given content.

Parameters:
  `characters` - the content as a character array

### SqlCharacterValue

public SqlCharacterValue(Reader reader, long length)
Create a new `SqlCharacterValue` for the given content.

Parameters:
  `reader` - the content reader
  `length` - the length of the content

### SqlCharacterValue

public SqlCharacterValue(InputStream asciiStream, long length)
Create a new `SqlCharacterValue` for the given content.

Parameters:
  `asciiStream` - the content as ASCII stream
  `length` - 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 interface `SqlTypeValue`
Parameters:
  `ps` - the PreparedStatement to work on
  `paramIndex` - the index of the parameter for which we need to set the value
  `sqlType` - the SQL type of the parameter we are setting
  `typeName` - the type name of the parameter (optional)
Throws:
  `SQLException` - if an SQLException is encountered while setting parameter values
See Also:
  - `Types`
  - `PreparedStatement.setObject(int, java.lang.Object, int)`