Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-17

"No such column" when getting results by index without alias

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: 1.1.1
    • Component/s: None
    • Labels:
      None
    • Environment:
      Tested on Windows and Linux

      Description

      Query:
      select count from table_a;

      Retrieve results using:
      int count = resultSet.getInt(1);

      Problem:
      Driver needs to translate index to a column name. In MySQLResultSetMetaData.getColumnName(index), the method getColumnInformation(column).getOriginalName() returns "". If I changed the code to this workaround:

      public String getColumnName(final int column) throws SQLException {
      String results = getColumnInformation(column).getOriginalName();
      if (results == null || "".equals(results))

      { results = getColumnInformation(column).getName(); }

      return results;
      }

      then it works. This is because getColumnInformation(column).getName() returns "count" which is what is needed in ColumnNameMap.getIndex(name).

      I don't know the code deep enough to tell if the workaround above is the best way to address the issue, please advise.

        Attachments

          Activity

            People

            • Assignee:
              wlad Vladislav Vaintroub
              Reporter:
              keith.chew Keith Chew
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h