result set null

I am working with servlets database connectivity.
I have a table in the dtatabse where only usernames and passwords r stored. I want to give an error message if the user is not at all presnt, ie, he is a new user.
the query is 'select * from table where username = 'user';
how to check for the null resultset ?,  
result.wasnull() checks only whether the last column read had this special value.
pls explain me with the code

the other question is can 2 or more than 2 queries can be run simultaneously. like depending upon the result set values of one query the other query should run.
can this be possible ?
Pls explain.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Create your statement object then execute your query like this:

ResultSet rs = stmt.executeQuery ("select * from table where username = 'user'");
if (
  System.out.println("Found at least 1 matching record...");
} else {
  System.out.println("Found no matching records...");

However, in general the best way to do this is to actually ask SQL to return you an integer which is the count of matching records - this will always return a value which will be 0 if no matches were found or more than 0 if there were. You do that like this...

ResultSet rs = stmt.executeQuery ("select count(*) from table where username = 'user'");
while (
  System.out.println("Found " + rs.getInt(1) + " matching records...");

If you are just running one query after another then you should get no real problems as long as the queries do not update or overlap into the same data.

Whether you can run two concurrent queries depends on whether your database driver supports it - the JDBC-ODBC bridge will not guarantee to work.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pbhagAuthor Commented:
hey thanks Jod, its working now,
I should have used if instead of while (
Now its perfectly woking.

but in the second one, I am still getting the probs, since the second query runs only if the result got from the first query matches with some particular value, so I need to run that query within the another.
What exactly is the query you are trying to perform? You can perform conditional queries within SQL or Java so I would need to know what it is you are trying to achieve.
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

pbhagAuthor Commented:
Adjusted points to 100
pbhagAuthor Commented:
am a colleague of priya,she has left us,so grading it myself,damn cookies.

Guess who ,u no me ,Jod
Personally I LOVE cookies. Mmmmm, chocolate chip.

But who are you?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.