I fire a SQL statement to start a procedure with only one input Parameter, a clob. But it doesn't work, and I don't know why.
Query:
private static final String ADD_DOCUMENTS =
"select * from table(Test.test_clob(in_document_clob => :cblob))";
Calling the query:
public void addDocuments(InputStream data, String name) throws IOException, SQLException {
byte[] byteArray = IOUtils.toByteArray(data);
SqlParameterSource paramSource = new MapSqlParameterSource().addValue("cblob",
new SqlLobValue(new ByteArrayInputStream(byteArray), byteArray.length, new DefaultLobHandler()), OracleTypes.CLOB);
final List<SomeResponse> query = this.template.query(ADD_DOCUMENTS, paramSource, new SomeResponseMapper(true));
}
I know so far, it works with strings as input, but not with clob's.
I'm getting this error:
java.lang.ArrayIndexOutOfBoundsException: Index 32768 out of bounds for length 32768
at oracle.sql.CharacterSet.convertJavaCharsToAL32UTF8Bytes(CharacterSet.java:1895)
at oracle.jdbc.driver.DBConversion.javaCharsToCHARBytes(DBConversion.java:832)
at oracle.jdbc.driver.DBConversion.javaCharsToCHARBytes(DBConversion.java:766)
When I try to call SqlLobValue without length param, I'm getting this error:
java.lang.IllegalArgumentException: Content type [[B] not supported for CLOB columns
at org.springframework.jdbc.core.support.SqlLobValue.setTypeValue(SqlLobValue.java:204)
at org.springframework.jdbc.core.StatementCreatorUtils.setValue(Statement CreatorUtils.java:292)
Many thanks for your help.
I tried to call when i try to call SqlLobValue without length param.
As @pmdba mentioned my Problem was the size limitation. Clob limit with streaming function are 32kb resolves to this error.
java.lang.ArrayIndexOutOfBoundsException: Index 32768 out of bounds for length 32768
at oracle.sql.CharacterSet.convertJavaCharsToAL32UTF8Bytes(CharacterSet.java:1895) at oracle.jdbc.driver.DBConversion.javaCharsToCHARBytes(DBConversion.java:832) at oracle.jdbc.driver.DBConversion.javaCharsToCHARBytes(DBConversion.java:766)