ArrayIndexOutOfBoundsException at com.mysql.cj.mysqla.io.Buffer#readInteger
Posted by: f worm
Date: April 18, 2018 02:53AM

I'm using mysql-connector-java-6.0.6.jar to connect mysql server, both 5.7.21 and MariaDB-10.1.22.
Eanble useServerPrepStmts, then execute a normal preparedStatement query, such as:

"select f1 from xxx"

The column f1 type is text/longtext, get the value with ResultSet.getString(1), if f1 has value, get the right value, however if f1 is null, it throw an exception:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at com.mysql.cj.mysqla.io.Buffer.readInteger(Buffer.java:288)
at com.mysql.cj.mysqla.result.BinaryBufferRow.getValue(BinaryBufferRow.java:231)
at com.mysql.cj.jdbc.result.ResultSetImpl.getString(ResultSetImpl.java:880)

While getObject(1) return null, because it check the null value first(call getNull).

I want use the specific type method, so I chose change the Buffer.readInteger method to avoid the error, check byteBuffer's length:

if (this.byteBuffer.length == position) {
return 0;
}

Is there some official suggestions to avoid this problem?
Thanks.

Options: ReplyQuote


Subject
Written By
Posted
ArrayIndexOutOfBoundsException at com.mysql.cj.mysqla.io.Buffer#readInteger
April 18, 2018 02:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.