I see that the following line of code:
Code: Select all
if(!rs.isAfterLast()){
Why would be that?
Furthermore instead of rs.isAfterLast() I could insert (!rw.getRow()==0) and I would have got the same result;
The_Nick
Moderator: admin
Code: Select all
if(!rs.isAfterLast()){
Code: Select all
while(result.next())//result is a valid ResultSet
{
System.out.println(result.getInt(1));
}
Ok, however why in the following code there is no need of such a check?admin wrote:It is not really required if you catch the exception in the filter and return false.
The reason given code uses it is because in dumpRS(), the loop uses while(rs.next()). So after the last rows is printed, the filter is invoked with the pointer pointing to "one after the last row". So now you can either expect an exception and catch it or avoid the exception by checking for isAfterLast.
HTH,
Paul.
Code: Select all
while(result.next())//result is a valid ResultSet
{
System.out.println(result.getInt(1));
}
In the implementation of evaluate in the example, it doesn't do this:To set the criteria for which rows in a FilteredRowSet object will be visible, you define a class that implements the Predicate interface. An object created with this class is initialized with the following:...
- The high end of the range within which values must fall
The low end of the range within which values must fall
Note that the range of values is inclusive, meaning that a value at the boundary is included in the range.
Code: Select all
return gpa > this.level;
Code: Select all
return gpa >= this.level;
To illustrate an approach, of courseAmbiorix wrote:Why would you go to the bother of creating a filter class when you could just include something like 'and GPA > 4.0' in the original select statement?
I was thinking more generally. What's the point of the FilterRowSet? Is it not always easier just to get the select statement to pick the rows that meet the criteria you want?admin wrote:To illustrate an approach, of courseAmbiorix wrote:Why would you go to the bother of creating a filter class when you could just include something like 'and GPA > 4.0' in the original select statement?
Users browsing this forum: No registered users and 18 guests