Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-6566

2.11.1 JDBC Component throws IndexOutOfBoundsException when SELECT returns 0 rows

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.11.1
    • None
    • camel-jdbc
    • None
    • Windows x64, Java 7 u 21, MS SQL Server, Apache Derby in-memory

    • Novice

    Description

      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

      Attachments

        1. JDBCEmptyResultTest.java
          3 kB
          Sebastian Plitt

        Issue Links

          Activity

            People

              Unassigned Unassigned
              s.plitt Sebastian Plitt
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: