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

Updatable result-set possible NPE when same field is repeated.

    XMLWordPrintable

    Details

      Description

      When using an updatable resultset (using ResultSet.CONCUR_UPDATABLE), If query concern only one table AND having same field repeat multiple time, getting a value using resultset.getXXX() from one of those repeated field will result in a NPE.

      example :

              stmt.execute("CREATE TABLE TT ( t1 varchar(50) NOT NULL, t2 varchar(50), PRIMARY KEY (t1))");
              stmt.execute("insert into tt values ('a', 'b'), ('c', 'd')");
              PreparedStatement preparedStatement = sharedConnection.prepareStatement("SELECT t1, t2, t1 as t3 FROM TT", ResultSet.FETCH_FORWARD, ResultSet.CONCUR_UPDATABLE);
              ResultSet rs = preparedStatement.executeQuery();
              while (rs.next()) {
                  rs.getObject(3); //will thow an NPE 
              }
      
      

      resulting error is :

      java.lang.NullPointerException
      	at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.getInternalObject(SelectResultSet.java:2099)
      	at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.getObject(SelectResultSet.java:1936)
      

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            diego dupin Diego Dupin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: