You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Willem Jiang (JIRA)" <ji...@apache.org> on 2014/02/28 04:49:19 UTC

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

     [ https://issues.apache.org/jira/browse/CAMEL-7251?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Willem Jiang resolved CAMEL-7251.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 2.13.0
                   2.12.4

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

> SqlProducer call twice the getResultSet on the PreparedStatement => This cause issue with HSQLDB (NPE)
> ------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-7251
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7251
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-sql
>    Affects Versions: 2.12.3
>            Reporter: Mathieu Boretti
>            Assignee: Willem Jiang
>             Fix For: 2.12.4, 2.13.0
>
>
> 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



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)