use:
(rs.next())
instead of:
if(rs!=null)
This will move the cursor to the first line initially, and the next line
subsequently.
(see the javadoc on the ResultSet methods)
Kate.
-----Original Message-----
From: s saravanan [mailto:[EMAIL PROTECTED]]
Sent: Friday, 17 November 2000 16:44
To: [EMAIL PROTECTED]
Subject: Resultset condition
Hi folks!
I have some doubt regarding Resultset validation. Here is the part of my
code:
String query="select * from userdetails where username='"+u1+"'";
ResultSet rs = stmt.executeQuery(query);
if(rs!=null)
{
out.println("Username is already in use !");
}
else
{
try
{
PreparedStatement ps=con.prepareStatement("insert into
userdetails(" + "username)" + "values('" +u1+ "'"+")");
ps.executeUpdate();
out.println("record inserted");
}
catch(Exception e)
{
out.println(e);
}
}
In the above code if-else is not working. So i need help how to validate
the resultset in IF statement. Compilation erroe is not there in the above
code, only runtime error is there.
I need in this way, if the username is already there in table , it should
flash message in the same html page "Username is already in use !".
otherwise it should insert record in table and flash message "record
inserted".
How to send the message to the same html page.
Help me with ur answer!!
saravanan.s
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
____________________________________________________________________________
________________________________________
IMPORTANT: This email is intended only for the use of the individual or
entity named above and may contain information that is confidential and
privileged. The views expressed in this e-mail are those of the author and
not of the company unless otherwise clearly indicated. When addressed to
our clients, any information or quotes contained in this e-mail are subject
to the terms and conditions relevant at that time to the matter being
addressed. If you are not the intended recipient and have received this
e-mail in error, please notify us immediately by return email or telephone
+61 8 93235555 and delete the e-mail and any attachments without using or
disclosing the contents in any way. If you are not the intended recipient
any dissemination, distribution or copying of this e-mail is strictly
prohibited. Before opening or using attachments, check them for viruses and
defects. Our liability is limited to re-supplying any affected attachments.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html