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

SelectResultSet method wasNull can't change once lastGetWasNull is set to true

    XMLWordPrintable

    Details

      Description

      org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet method wasNull can't change once lastGetWasNull is set to true

      So this simple code taken from MyBatis always returns null values after that lastGetWasNull is set to true.
      This is caused from the org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet wasNull implementation method that returns always true after the first read that sets lastGetWasNull = true, for example reading a LocalDateTime "0000-00-00 00:00:00" from the db.
      That makes the read of all the following column values null.

      @Override
        public T getResult(ResultSet rs, String columnName) throws SQLException {
          T result;
          try {
            result = getNullableResult(rs, columnName);
          } catch (Exception e) {
            throw new ResultMapException("Error attempting to get column '" + columnName + "' from result set.  Cause: " + e, e);
          }
          if (rs.wasNull()) {
            return null;
          } else {
            return result;
          }
        }
      

      The documentation of the ResultSet interface method wasNull tells:
      "true if the last column value read was SQL NULL and false otherwise"
      so I think that that value should be reset to false in some way.

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            daniele.maddaluno Daniele Maddaluno
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: