| Author |
The ResultSet
|
Bhavik patel
Ranch Hand
Joined: Feb 20, 2007
Posts: 49
|
|
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()?
|
Bhavik Patel
Glassfish Consultancy service At http://www.jmatrix.in
|
 |
Srikanth Ramu
Ranch Hand
Joined: Feb 20, 2007
Posts: 76
|
|
|
false will be returned if the resultset object has no rows.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
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'";
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
mnadeem chishti
Greenhorn
Joined: Aug 07, 2006
Posts: 11
|
|
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()?
|
 |
 |
|
|
subject: The ResultSet
|
|
|