Thank you for your reply.I'm developing a UI using struts which will get the emailid from the user,I've set emailid as primary key in mysql db.So if the same emailid is given in the database it'll throw error.This can be viewed in mysql command line client.
But how to do this writing code.I need to check whether the same emailid exists in db,if it doesn't I should insert it in the user_table otherwise in the existing_user_table.
I know its simple ,pl help me
> But how to do this writing code.I need to check
> whether the same emailid exists in db,if it doesn't I
> should insert it in the user_table otherwise in the
> existing_user_table.
Sounds simple. Select to see if that id exists. If it doesn't then insert.
What part are you having problems with? You need to be specific about the code you are having trouble with. (I don't want to explain everything if you understand how to do 90% of it).
thanks for your time..I know that it will return zero if there are no records,i can understand the whole thing but 2 write the code is the problem,what code should i write to know whether it returns zero,ism having problem there..I'm 95% over but this 5% is driving me nuts..its simple..but I'm not able 2 do it...pl help me
yes,my project will be over if I'm done with this...If my email_id already exists I need to insert into existing_user table..if the email id is new i should insert into the user_table...i need the code..I'm using jdbc in struts frame work .this is my first project...pl help me..I'm a newbie to all this
> yes,my project will be over if I'm done with
> this...If my email_id already exists I need to insert
> into existing_user table..if the email id is new i
> should insert into the user_table...i need the
> code..I'm using jdbc in struts frame work .this is my
> first project...pl help me..I'm a newbie to all this
i m not much familiar with struts but as far as JDBC is concerned next() returns a boolean value... so u can just check using this method that your email id already exists or not and if it already exists u just insert it into your existing table...
.....
.....
ResultSet rs = stmt.executeQuery("select emailid from table where mailid='mailid_user_enters'");
if(rs.next())
{
//if mail id already present
stmt.executeUpdate("insert into ...."); // insert into already existing_user table
}
else
{
//if mail id doesn't exist
stmt.executeUpdate("insert into ..."); // insert into the user-table
}
i m not very clear what u exactly r asking for but may b this can help u...