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 ?
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.)
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com