• 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

The ResultSet

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,


I am new to JDBC....

String query="SELECT * FROM Login WHERE username="+"bhavik";

now suppose,if the user name "bhavik" does not exist...
what will be returned by the method stmt.executeQuery(query);?
and i knoew it will be anythingf except null...

what will be returned by rs.next()?
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
false will be returned if the resultset object has no rows.
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bhavik,
If a SQL statement is valid and doesn't match anything, JDBC returns an empty result set. This means that rs.next() returns false.

Note that the SQL in your example is not considered valid by most databases. It needs single quotes around the value:
String query="SELECT * FROM Login WHERE username='bhavik'";
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bhavik patel:
Hello Friends,


I am new to JDBC....

String query="SELECT * FROM Login WHERE username="+"bhavik";

now suppose,if the user name "bhavik" does not exist...
what will be returned by the method stmt.executeQuery(query);?
and i knoew it will be anythingf except null...

what will be returned by rs.next()?

 
reply
    Bookmark Topic Watch Topic
  • New Topic