This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-17. For the latest, interactive version please visit https://mariadb.com/kb/.

ArrayIndexOutOfBoundsException on connect to MySQL server

Hello!

Attempting to connect to a MySQL 5.1.73 server using MariaDB Connector/J 2.0.1 in Java 8 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)

Any help would be greatly appreciated! Thank you!

Answer Answered by J. Lewis Muir in this comment.

Thanks for fixing it in 2.0.2-SNAPSHOT! That works!

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.