Click here to Skip to main content
15,917,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public boolean registerCustomer(CustomerBean obj)
{
String sql1;
PreparedStatement ps = null;
try {
sql1 = "INSERT into Registration values(?,?,?,?)";//registration is working Fine
ps = conn.prepareStatement(sql1);
ps.setString(1, obj.getName());
ps.setString(2, obj.getEmailId());
ps.setString(3, obj.getPassword());
ps.setString(4, obj.getCountry());
int ret = ps.executeUpdate();//here I want to send Email id and Password to another table
if(ret > 0) {
conn.commit();
return true;
}
} catch(SQLException sqe) {
sqe.printStackTrace();
}
return false;
}

What I have tried:

I tried to use insert Statement again after executeUpdate(). But it doesn't work.
Posted
Updated 17-Jan-18 21:46pm
Comments
Mohibur Rashid 17-Jan-18 17:30pm    
Why can't you wriye a similar query?

1 solution

see this

C#
public boolean registerCustomer(CustomerBean obj) 
{
String sql1;
PreparedStatement ps = null;
try {
sql1 = "INSERT into Registration values(?,?,?,?)";//registration is working Fine
ps = conn.prepareStatement(sql1);
ps.setString(1, obj.getName());
ps.setString(2, obj.getEmailId());
ps.setString(3, obj.getPassword());
ps.setString(4, obj.getCountry());
int ret = ps.executeUpdate();//here I want to send Email id and Password to another table 


if(ret > 0) {
conn.commit();
return true;
}

//update line

sql1 = "INSERT into AnotherRegistration values(?,?)";//registration is working Fine
ps = conn.prepareStatement(sql1);
ps.setString(2, obj.getEmailId());
ps.setString(3, obj.getPassword());

int ret = ps.executeUpdate();

if(ret > 0) {
conn.commit();
return true;
}
} catch(SQLException sqe) {
sqe.printStackTrace();
}
return false;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900