JDK-6322636 : FilteredRowSetImpl: throws NPE on attempt to update a DATE column
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.sql
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-09-12
  • Updated: 2012-03-23
  • Resolved: 2006-08-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b97Fixed
Related Reports
Relates :  
Description
Run the example code below:

import javax.sql.RowSet;
import javax.sql.rowset.FilteredRowSet;
import javax.sql.rowset.RowSetMetaDataImpl;
import java.sql.ResultSetMetaData;
import java.sql.Types;

public class Failure1 {

    private static String filteredRowSetClass = "com.sun.rowset.FilteredRowSetImpl";

    public static void main(String[] args)  {

        boolean passed = false;

        try {
            FilteredRowSet frs = (FilteredRowSet)Class.forName(filteredRowSetClass).newInstance();
            initInstance(frs);
            passed = true;
        }
        catch (Exception e) {
            System.out.println(e.toString());
        }

        System.out.println("Test :" + (passed ? "passed" : "failed"));
    }


    protected static void initInstance(FilteredRowSet frs) throws Exception {

        RowSetMetaDataImpl rsmdi;
        rsmdi = new RowSetMetaDataImpl();
        frs.setType(RowSet.TYPE_SCROLL_INSENSITIVE);

        rsmdi.setColumnCount(3);
        rsmdi.setColumnType(1, Types.VARCHAR);
        rsmdi.setColumnType(2, Types.INTEGER);
        rsmdi.setColumnType(3, Types.VARCHAR);

        rsmdi.setColumnName(1, "First");
        rsmdi.setColumnName(2, "Second");
        rsmdi.setColumnName(3, "Third");

        rsmdi.setNullable(1, ResultSetMetaData.columnNoNulls);
        rsmdi.setNullable(3, ResultSetMetaData.columnNullable);
        frs.setMetaData(rsmdi);

        frs.moveToInsertRow();

        frs.updateString(1, "string data");
        frs.updateInt(2, 1);
        frs.updateString(3, "StringCol31");
        frs.insertRow();

        frs.moveToInsertRow();

        frs.updateString(1, "StringCol12");
        frs.updateInt(2, 2);
        frs.updateString(3, "StringCol32");
        frs.insertRow();

        frs.moveToCurrentRow();
        frs.beforeFirst();
    }
}
FilteredRowSetImpl: throws NPE on attempt to update a DATE column (JDK build #86)

import javax.sql.RowSet;
import javax.sql.rowset.FilteredRowSet;
import javax.sql.rowset.RowSetMetaDataImpl;
import java.sql.ResultSetMetaData;
import java.sql.Types;
import java.sql.Date;

public class Failure2 {

    private static String filteredRowSetClass = "com.sun.rowset.FilteredRowSetImpl";

    public static void main(String[] args)  {

        boolean passed = false;

        try {
            FilteredRowSet frs = (FilteredRowSet)Class.forName(filteredRowSetClass).newInstance();
            initInstance(frs);
            passed = true;
        }
        catch (Exception e) {
            System.out.println(e.toString());
        }

        System.out.println("Test :" + (passed ? "passed" : "failed"));
    }


    protected static void initInstance(FilteredRowSet frs) throws Exception {

        RowSetMetaDataImpl rsmdi;
        rsmdi = new RowSetMetaDataImpl();
        frs.setType(RowSet.TYPE_SCROLL_INSENSITIVE);

        rsmdi.setColumnCount(4);
        rsmdi.setColumnType(1, Types.VARCHAR);
        rsmdi.setColumnType(2, Types.INTEGER);
        rsmdi.setColumnType(3, Types.VARCHAR);
        rsmdi.setColumnType(4, Types.DATE);

        rsmdi.setColumnName(1, "First");
        rsmdi.setColumnName(2, "Second");
        rsmdi.setColumnName(3, "Third");
        rsmdi.setColumnName(4, "Fourth");

        rsmdi.setNullable(1, ResultSetMetaData.columnNoNulls);
        rsmdi.setNullable(3, ResultSetMetaData.columnNullable);
        frs.setMetaData(rsmdi);

        frs.moveToInsertRow();

        frs.updateString(1, "string data");
        frs.updateInt(2, 1);
        frs.updateString(3, "StringCol31");
        frs.updateDate(4, new Date(1));
        frs.insertRow();

        frs.moveToInsertRow();

        frs.updateString(1, "StringCol12");
        frs.updateInt(2, 2);
        frs.updateString(3, "StringCol32");
        frs.updateDate(4, new Date(2));
        frs.insertRow();

        frs.moveToCurrentRow();
        frs.beforeFirst();
    }
}

Comments
EVALUATION Few methods like updateDate() had not been modified to check for null. It is not an issue with updateString(). This has been fixed.
19-06-2006

EVALUATION Fixed. If Range has not been defined, all the rows can be updated.
26-05-2006