Camel
  1. Camel
  2. CAMEL-7251

SqlProducer call twice the getResultSet on the PreparedStatement => This cause issue with HSQLDB (NPE)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.12.3
    • Fix Version/s: 2.12.4, 2.13.0
    • Component/s: camel-sql
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      The SqlProducer class use the following lines of code :

      ResultSet rs = ps.getResultSet();
      SqlOutputType outputType = getEndpoint().getOutputType();
      log.trace("Got result list from query: {}, outputType={}", rs, outputType);
      if (outputType == SqlOutputType.SelectList)

      { List<Map<String, Object>> data = getEndpoint().queryForList(ps.getResultSet()); ................................. }

      else if (outputType == SqlOutputType.SelectOne)

      { Object data = getEndpoint().queryForObject(ps.getResultSet()); ................................. }

      else

      { throw new IllegalArgumentException("Invalid outputType=" + outputType); }

      The problem is that the ResultSet is retrieved at the start, and then only used for the log. Later, when the result set is required, a new call to getResultSet is done. It is an issue with HSQL DB (tested with version 2.3.0 and 2.3.2 of HSQL DB), which in this case return null for the second call.

      As the ResultSet is already available in a variable "rs", I would recommand to use this variable to replace the two last call to ps.getResultSet().

      Thanks

        Activity

        Hide
        ASF GitHub Bot added a comment -

        GitHub user boretti opened a pull request:

        https://github.com/apache/camel/pull/104

        CAMEL-7251 SqlProducer call twice the getResultSet on the PreparedStatement => This cause issue with HSQLDB (NPE)

        According https://issues.apache.org/jira/browse/CAMEL-7251

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/boretti/camel camel-7251

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/camel/pull/104.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #104


        commit e44f258a2f4fac85dcb67c48a9dc9ae129aa87e8
        Author: boretti <mathieu.boretti@gmail.com>
        Date: 2014-02-27T20:56:04Z

        SqlProducer call twice the getResultSet on the PreparedStatement => This
        cause issue with HSQLDB (NPE)


        Show
        ASF GitHub Bot added a comment - GitHub user boretti opened a pull request: https://github.com/apache/camel/pull/104 CAMEL-7251 SqlProducer call twice the getResultSet on the PreparedStatement => This cause issue with HSQLDB (NPE) According https://issues.apache.org/jira/browse/CAMEL-7251 You can merge this pull request into a Git repository by running: $ git pull https://github.com/boretti/camel camel-7251 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/camel/pull/104.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #104 commit e44f258a2f4fac85dcb67c48a9dc9ae129aa87e8 Author: boretti <mathieu.boretti@gmail.com> Date: 2014-02-27T20:56:04Z SqlProducer call twice the getResultSet on the PreparedStatement => This cause issue with HSQLDB (NPE)
        Hide
        Willem Jiang added a comment -

        Applied the patch with thanks to Mathieu into master and camel-2.12.x branches.

        Show
        Willem Jiang added a comment - Applied the patch with thanks to Mathieu into master and camel-2.12.x branches.
        Hide
        ASF GitHub Bot added a comment -

        Github user boretti closed the pull request at:

        https://github.com/apache/camel/pull/104

        Show
        ASF GitHub Bot added a comment - Github user boretti closed the pull request at: https://github.com/apache/camel/pull/104

          People

          • Assignee:
            Willem Jiang
            Reporter:
            Mathieu Boretti
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development