4 Replies Latest reply on Jan 12, 2010 5:30 PM by unwired unwired

    camel jdbc problem

    unwired unwired Newbie

      I have a simple query

       

      select id AS identifier from service

       

      that I am running through the camel jdbc component.

       

      This fails with a SQLException

       

      Column 'id' not found.

       

      I had a look at the source code and it uses ResultSetMetaData to get at the column names/labels to create entries in a java Map

       

      The source uses getColumnName() rather than getColumnLabel() and fails because it cannot a find a resultset with a column named id. (See line 113 below}

       

       

       /**
      101      * Sets the result from the ResultSet to the Exchange as its OUT body.
      102      */
      103      protected void setResultSet(Exchange exchange, ResultSet rs) throws SQLException {
      104      ResultSetMetaData meta = rs.getMetaData();
      105      
      106      int count = meta.getColumnCount();
      107      List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
      108      int rowNumber = 0;
      109      while (rs.next() && (readSize == 0 || rowNumber < readSize)) {
      110      Map<String, Object> row = new HashMap<String, Object>();
      111      for (int i = 0; i < count; i++) {
      112      int columnNumber = i + 1;
      113      String columnName = meta.getColumnName(columnNumber);
      114      row.put(columnName, rs.getObject(columnName));
      115      }
      116      data.add(row);
      117      rowNumber++;
      118      }
      119      exchange.getOut().setHeader(JdbcConstants.JDBC_ROW_COUNT, rowNumber);
      120      exchange.getOut().setBody(data);
      121      } 
      

       

      Is this a known issue or expected behaviour ?

       

      Thanks