Quantcast
Channel: MySQL Forums - Connector/J, JDBC and Java
Viewing all articles
Browse latest Browse all 884

ArrayIndexOutOfBoundsException at com.mysql.cj.mysqla.io.Buffer#readInteger (no replies)

$
0
0
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.

Viewing all articles
Browse latest Browse all 884

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>