• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question regarding FilteredRowSet.

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good day all!

I am straggling to understand the output (1Z0-804 full test number-3, question-3 JDBC)
The database table is given, and the code. What can be seen in the ResultSet object after the execution.

2. The following filter code -

3. and the following code fragment:


The table:
STUDENT:
SID NAME GPA
1 Amy 3.5
2 Bob 3.6
3 Cathy 4.1
4 David 4.3
5 Edward 2.9

So according to the filter implementation the output should be: Cathy - 4.1 AND David - 4.3
I could say I guessed the right answer, according to the input it was clear, but wanted to understand the implementation of the filter deeper, so tried the complete example provided in the question.


BUT the output from this code is not just those two: Cathy - 4.1 AND David - 4.3! Its all of them. How come? The evaluate method should return FALSE if the GPA < then provided during the construction of the filter? i.e the output should have Cathy - 4.1 AND David - 4.3 WHERE gpa > level.
I am totally confused.

Will appreciate any help.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your own code, the filter is applied AFTER the execute line making the filter taking no effect.

The line order is important for JDBC logic.
 
Aleksandra Semenova
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In your own code, the filter is applied AFTER the execute line making the filter taking no effect.

The line order is important for JDBC logic.



Hi! Thank you for the reply. I didn't specifically mentioned this, but tried replacing lines as well, the output is the same.
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tested your program and I got the expected output = only 2 rows

Don't let the output from the filter fool you, comment these out and just have the dumpXXX method output stuff.

To keep it simple you can just do for the output:


 
Aleksandra Semenova
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I tested your program and I got the expected output = only 2 rows

Don't let the output from the filter fool you, comment these out and just have the dumpXXX method output stuff.



Thank's. There was nothing wrong with the code, besides Filter replacement. Just messy output, didn't see the names next to two gpa's higher then 4.0;
Feels stupid, reading the code itself 100 times, and not paying attention to the output.

Thanks again.
Sometimes attention is more important than the knowledge, it's a pity exam has about 25% of questions testing your attention.
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic