Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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: 40913
840
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()?

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic