• 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

My sql query returns zero rows

Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have written a servlet code for checking if the username is already exists in the database for registering, however my sql query returns zero rows. I have no idea of what is happening in the query.

rs.getRow() returns value zero though there are 2 records in the database with the username I have given. I wanted to print the sql query to check if the query is working properly, i do not understand how to print the query because of the prepared statement. is there a possible way to print the sql query ?

thanks in advance!!
Posts: 27228
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That code doesn't tell you anything about what the query returns. In fact all it does is to run the query, ignore the data, and ask "What is the current row?"

And since you haven't tried to read anything from the query, the current row is naturally zero.

Any tutorial I have ever seen on JDBC shows you how to read through a ResultSet using the rs.next() method. I would suggest you have a look at some JDBC tutorials.

(By the way: there is nothing special about servlets. So the fact that you have problems with JDBC code doesn't make this a servlets problem just because you happened to put the code in a servlet. I'm going to move the post to the JDBC forum, since it's a question about JDBC.)
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic