[CONJ-479] ArrayIndexOutOfBoundsException on connect to MySQL 5.1.73 Created: 2017-05-26  Updated: 2017-06-01  Resolved: 2017-05-29

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 2.0.1
Fix Version/s: 1.6.1, 2.0.2

Type: Bug Priority: Major
Reporter: J. Lewis Muir Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

MariaDB Connector/J 2.0.1 is unable to connect to a MySQL 5.1.73 server. In Java 8, attempting to connect like this:

try (Connection c = DriverManager.getConnection(url, user, new String(password))) {
  System.out.printf("Connection class:%n%s%n", c.getClass().getName());
}

where url is something like this:

"jdbc:mariadb://my.host.name:3306/MYDB"

results in the following stack trace:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
	at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.readNextValue(SelectResultSet.java:481)
	at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.fetchAllResults(SelectResultSet.java:338)
	at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.<init>(SelectResultSet.java:209)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readResultSet(AbstractQueryProtocol.java:1273)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1033)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:982)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.readRequestSessionVariables(AbstractConnectProtocol.java:498)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.readPipelineAdditionalData(AbstractConnectProtocol.java:544)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connect(AbstractConnectProtocol.java:410)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1013)
	at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:481)
	at org.mariadb.jdbc.Driver.connect(Driver.java:103)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:247)
	at Main.main(Main.java:16)

This issue was initially a question.



 Comments   
Comment by Diego Dupin [ 2017-05-29 ]

Issue confirmed.
Since in MySQL 5.1 capabilities rely only on 2 bytes, 2 to 4 bytes capabilities are set to 0xFFFF, not to 0x0000.
This cause an issue with resultset because driver think that EOF_PACKET is deprecated, but server still send it.

Comment by Diego Dupin [ 2017-05-29 ]

correction SNAPSHOT is available using :

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>
 
<dependencies>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>2.0.2-SNAPSHOT</version>
    </dependency>
</dependencies>

or download directly from maven repo : https://oss.sonatype.org/content/repositories/snapshots/org/mariadb/jdbc/mariadb-java-client/2.0.2-SNAPSHOT/

Comment by J. Lewis Muir [ 2017-05-29 ]

Thank you! I confirm that 2.0.2-SNAPSHOT fixes the problem!

Comment by Diego Dupin [ 2017-06-01 ]

for information this concern only MySQL/MariaDB 5.1

Generated at Thu Feb 08 03:15:58 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.