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();
}
}