You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Sebastian Plitt (JIRA)" <ji...@apache.org> on 2013/07/22 13:34:52 UTC

[jira] [Created] (CAMEL-6566) 2.11.1 JDBC Component throws IndexOutOfBoundsException when SELECT returns 0 rows

Sebastian Plitt created CAMEL-6566:
--------------------------------------

             Summary: 2.11.1 JDBC Component throws IndexOutOfBoundsException when SELECT returns 0 rows
                 Key: CAMEL-6566
                 URL: https://issues.apache.org/jira/browse/CAMEL-6566
             Project: Camel
          Issue Type: Bug
          Components: camel-jdbc
    Affects Versions: 2.11.1
         Environment: Windows x64, Java 7 u 21, MS SQL Server, Apache Derby in-memory
            Reporter: Sebastian Plitt


JDBC component throws an IndexOutOfBoundsException when the result is empty.
The behaviour has been tested with a MS SQL Server database and a Apache Derby in-memory database. This bug is probably valid for any database system.

Stacktrace: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.rangeCheck(Unknown Source)
	at java.util.ArrayList.get(Unknown Source)
	at o.a.c.c.j.JdbcProduce.setResultSet(JdbcProducer.java:226)
	at o.a.c.c.j.J.createAndExecuteSqlStatement(JdbcProducer.java:146)
	at o.a.c.c.j.J.processingSqlBySettingAutoCommit(JdbcProducer.java:82)
	at o.a.c.c.j.J.process(JdbcProducer.java:63)

Cause: The first result row is accessed to determine the column names when setting the header JDBC_COLUMN_NAMES in method setResultSet(). If the result is empty there is no first result row. 
Apache Camel 2.11.0 doen't set this header and is not affected by this bug.

Possible Workaround: Only set header JDBC_COLUMN_NAMES if data.size() > 0



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira