I'm trying to use FilterRowSet to filter the appropriate values from database query. This is my code:
// Initialize
FilteredRowSet rowset = new FilteredRowSetImpl();
// Set the query string
rowset.setCommand("SELECT * FROM student");
rowset.setUrl("jdbc:mysql://127.0.0.1/test");
rowset.setUsername("root");
rowset.setPassword("");
// Execute to get a result set
rowset.execute();
System.out.println(rowset.first()); // Output: true
rowset.setFilter(new MyStringFilter("matcher", "column_name")); // Add condition to my filter rowset
System.out.println(rowset.first()); // Output: false
The problem is my rowset's pointer cannot be set after I set the filter condition, which is making it impossible to parse through it (or something similar) at later point of time.
Is this a bug or something that I am not aware of, when using the FilteredRowSet class?