I'm calling a complex stored procedure from Java that works
fine in AquaDataStudio (a Java SQL tool). Both my JBoss application and AquaDataStudio use the same JDBC driver. When running the Java application, the CallableStatement.execute() line throws this exception:
14:34:10,797 ERROR [EmailBounceControllerDAO] Unable to execute statement
java.lang.ArrayIndexOutOfBoundsException: -21624
at net.avenir.jdbc3.m.lb(Protocol.java)
at net.avenir.jdbc3.m.eb(Protocol.java)
at net.avenir.jdbc3.m.hb(Protocol.java)
at net.avenir.jdbc3.m.query(Protocol.java)
at net.avenir.jdbc3.b.c(Statement.java)
at net.avenir.jdbc3.cb.a(CallableStatement.java)
at net.avenir.jdbc3.cb.execute(CallableStatement.java)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.execute(WrappedPreparedStatement.java:183)
at com.imcadmin.actor.emailbouncecontroller.EmailBounceControllerDAO.persistBouncedEmail(EmailBounceControllerDAO.java:212)
at com.imc.quartz.jobs.BouncedMailJob.execute(BouncedMailJob.java:313)
at org.quartz.core.JobRunShell.run(JobRunShell.java:195)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
When commenting out the guts in the procedure, it works fine from Java (but of course doesn't do anything).
The relevant Java code chunk is:
callableStatement = connection.prepareCall(
"{call imc.IMC.p_EmailDeliveryFailure(?, ?, ?, ?, ?, ?, ?)}");
logger.debug("call prepared");
callableStatement.setLong(1, campaignScheduleId);
callableStatement.setLong(2, campaignLetterId);
callableStatement.setString(3, sqlSent);
callableStatement.setString(4, failureType);
callableStatement.setString(5, emailAddress);
callableStatement.setString(6, userMessage);
callableStatement.setString(7, messageContent);
logger.debug("parameters set"); // and an output of vars shows it's set correctly
callableStatement.execute(); // exception thrown here (with execute() or executeUpdate())
and using debug statements I can see the variables are correctly set.
I believe I'm seeing a failure in the driver to handle the complex procedure (a series of IF's, SELECTs, INSERTs, and UPDATEs - don't ask - it's complex).
I'm using Java5 on MacOSX 10.4.3 (deployed on Fedora Core 3), SQL Server 2000 on Windows 2003 Server, and the Avenir JDBC driver.
Does anyone have any opinions on this? Confirmation that this kind of thing happens with valid procedures? Or thoughts of how to get around this?
- Thanks!