Re: ArrayIndexOutOfBoundsException problems
Posted by: Mark Matthews
Date: February 01, 2005 05:57PM

Jonathan Gordon wrote:
> I'm having intermittent problems with Connector/J
> when I stress test my web application using
> connection pooling (c9p0). The main exception I
> receive is an ArrayIndexOutOfBoundsException.
>
> I'm using MySQL server on Linux: mysql Ver 14.7
> Distrib 4.1.8, for pc-linux (i686)
> Connector/J on Windows:
> mysql-connector-java-3.1.6
> JDK:
> java version "1.5.0_01"
> Java(TM) 2 Runtime Environment, Standard Edition
> (build 1.5.0_01-b08)
> Java HotSpot(TM) Client VM (build 1.5.0_01-b08,
> mixed mode, sharing)
>
> Here's the stack trace:
>
> -- BEGIN STACK TRACE --
> Caused by: java.sql.SQLException:
> java.lang.ArrayIndexOutOfBoundsException: 82
> at
> com.mysql.jdbc.ServerPreparedStatement.executeInte
> rnal(ServerPreparedStatement.java:994)
> at
> com.mysql.jdbc.PreparedStatement.executeQuery(Prep
> aredStatement.java:1657)
> at
> com.mchange.v2.c3p0.impl.NewProxyPreparedStatement
> .executeQuery(NewProxyPreparedStatement.java:71)
> at
> net.sf.hibernate.impl.BatcherImpl.getResultSet(Bat
> cherImpl.java:83)
> at
> net.sf.hibernate.loader.Loader.getResultSet(Loader
> .java:794)
> at
> net.sf.hibernate.loader.Loader.doQuery(Loader.java
> :188)
> at
> net.sf.hibernate.loader.Loader.doQueryAndInitializ
> eNonLazyCollections(Loader.java:132)
> at
> net.sf.hibernate.loader.Loader.loadEntity(Loader.j
> ava:830)
> at
> net.sf.hibernate.loader.Loader.loadEntity(Loader.j
> ava:850)
> at
> net.sf.hibernate.loader.EntityLoader.load(EntityLo
> ader.java:57)
> at
> net.sf.hibernate.loader.EntityLoader.load(EntityLo
> ader.java:49)
> at
> net.sf.hibernate.persister.EntityPersister.load(En
> tityPersister.java:420)
> ... 58 more
> -- END STACK TRACE --
>
> Additionally, I will sometimes get this
> exception:
>
> -- BEGIN STACK TRACE --
> java.sql.SQLException: Unknown character set index
> for field '24393' received from server.
> at
> com.mysql.jdbc.Connection.getCharsetNameForIndex(C
> onnection.java:1598)
> at
> com.mysql.jdbc.Field.<init>(Field.java:166)
> at
> com.mysql.jdbc.MysqlIO.unpackField(MysqlIO.java:62
> 5)
> at
> com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:4
> 03)
> at
> com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate
> (MysqlIO.java:1902)
> at
> com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java
> :1350)
> at
> com.mysql.jdbc.ServerPreparedStatement.serverExecu
> te(ServerPreparedStatement.java:1390)
> at
> com.mysql.jdbc.ServerPreparedStatement.executeInte
> rnal(ServerPreparedStatement.java:957)
> at
> com.mysql.jdbc.PreparedStatement.executeQuery(Prep
> aredStatement.java:1657)
> at
> com.p6spy.engine.logging.P6LogPreparedStatement.ex
> ecuteQuery(P6LogPreparedStatement.java:172)
> at
> com.mchange.v2.c3p0.impl.NewProxyPreparedStatement
> .executeQuery(NewProxyPreparedStatement.java:71)
> at
> net.sf.hibernate.impl.BatcherImpl.getResultSet(Bat
> cherImpl.java:83)
> at
> net.sf.hibernate.loader.Loader.getResultSet(Loader
> .java:794)
> at
> net.sf.hibernate.loader.Loader.doQuery(Loader.java
> :188)
> at
> net.sf.hibernate.loader.Loader.doQueryAndInitializ
> eNonLazyCollections(Loader.java:132)
> at
> net.sf.hibernate.loader.Loader.loadEntity(Loader.j
> ava:830)
> at
> net.sf.hibernate.loader.Loader.loadEntity(Loader.j
> ava:850)
> at
> net.sf.hibernate.loader.EntityLoader.load(EntityLo
> ader.java:57)
> at
> net.sf.hibernate.loader.EntityLoader.load(EntityLo
> ader.java:49)
> at
> net.sf.hibernate.persister.EntityPersister.load(En
> tityPersister.java:420)
> at
> net.sf.hibernate.impl.SessionImpl.doLoad(SessionIm
> pl.java:2044)
> at
> net.sf.hibernate.impl.SessionImpl.doLoadByClass(Se
> ssionImpl.java:1918)
> at
> net.sf.hibernate.impl.SessionImpl.internalLoad(Ses
> sionImpl.java:1880)
> at
> net.sf.hibernate.type.ManyToOneType.resolveIdentif
> ier(ManyToOneType.java:68)
> at
> net.sf.hibernate.type.EntityType.resolveIdentifier
> (EntityType.java:215)
> at
> net.sf.hibernate.type.EntityType.nullSafeGet(Entit
> yType.java:154)
> at
> net.sf.hibernate.impl.IteratorImpl.postNext(Iterat
> orImpl.java:71)
> at
> net.sf.hibernate.impl.IteratorImpl.next(IteratorIm
> pl.java:91)
>
> -- END STACK TRACE --
>
> Examining the source for com.mysql.jdbc.Connection
> at the first line of the exception:
> at
> com.mysql.jdbc.Connection.getCharsetNameForIndex(C
> onnection.java:1598)
>
> shows that the SQLException is thrown when another
> ArrayIndexOutOfBoundsException is encountered.
>
> Any idea of what could be causing these problems?
> I saw an earlier post saying this problem was
> fixed moving from 3.0.16 to 3.1.16 but that
> doesn't appear to be the case in my instance.
>
> Thanks,
>
> Jonathan.

Jonathan, looks like a protocol-level error. I'd first try upgrading to the nightly snapshot of 3.1 from http://downloads.mysql.com/snapshots.php and see if that solves your problem.

If that doesn't fix things, we'd need to see the output from your program after you've enabled 'packetDebug=true', so we can see what data was 'on the wire' when the exception was thrown.

You can also outright disable server-side prepared statements, which still have some maturing to do, by adding 'useServerPrepStmts=false' to your JDBC URL. In many cases, you will not notice a performance difference.

-Mark

Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html

Options: ReplyQuote


Subject
Written By
Posted
Re: ArrayIndexOutOfBoundsException problems
February 01, 2005 05:57PM


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.