My Oracle Support Banner

setAsciiStream With Non-ASCII Characters Fails With ArrayIndexOutOfBoundException In executeUpdate (Doc ID 369798.1)

Last updated on FEBRUARY 03, 2019

Applies to:

JDBC - Version: 10.1
This problem can occur on any platform.


When using PreparedStatement.setAsciiStream to bind a byte array >4096 bytes to a CLOB column,

StringBuffer longString = new StringBuffer (4096);
for (int i=0; i<5000; i++)
    longString.append ('Ü');
PreparedStatement prep = conn.prepareStatement ("insert into testclobs values ('test', ?)");
ByteArrayInputStream data = new ByteArrayInputStream((longString.toString()).getBytes());
prep.setAsciiStream(1, data, longString.length());

the executeUpdate() operation fails with

java.lang.ArrayIndexOutOfBoundsException: 4096
  at oracle.sql.CharacterSet.convertJavaCharsToUTFBytes(
  at oracle.jdbc.driver.DBConversion.javaCharsToCHARBytes(
  at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(
  at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(

when the byte array contains a non-ASCII value.


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.