Uploaded image for project: 'ServiceMix'
  1. ServiceMix
  2. SM-911

JDBCComponent: The first column index is 1 in a result from sql query (non zero)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.1
    • 3.1.1, 3.2
    • servicemix-components
    • None
    • apache-servicemix-3.1-incubating
      database: mysql (with mysql-connector-java-5.0.3 driver)

    Description

      The first column index in a result from a sql query to database is 1, non 0.

      So,
      1) in 'getUniqueColumnNames()' method, when we want to get column names from 'metaData' result, we must to start the count in i = 1
      [ * metaData.getColumnName(i ); ---> the first column is 1, the second column is 2...] :

      BUG:

       
      for (int i = 0; i < metaData.getColumnCount(); i++)
      

      IT SHOULD BE:

       
      for (int i = 1; i <= metaData.getColumnCount(); i++) {
      

      2) in 'toXmlSource()' method:

      BUG:

       
       for (int i=1; i<=colCount; i++) {
            buff.append(colNames[i].toLowerCase() + "='" + rs.getString(i) + "' ");
      

      IT SHOULD BE:

       
      for (int i=0; i<colCount; i++) { 
           buff.append(colNames[i].toLowerCase() + "='" + rs.getString(i + 1) + "' ");   
                                   --> index in 'colNames' starts in 0 and index in 'rs' starts in 1
      

      Attachments

        Activity

          People

            gnodet Guillaume Nodet
            junglika Jorge Rodríguez Pedrianes
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 10m
                10m
                Remaining:
                Remaining Estimate - 10m
                10m
                Logged:
                Time Spent - Not Specified
                Not Specified