我需要检查用户名是否存在db
。如果它存在,我应该说已经存在..如果不是,我应该插入db
以下代码:
ResultSet rs=preparedstatement.executeQuery("select *from re where username='"+unt.getText()+"';");
if(rs!=null){
while(rs.next()){
preparedstatement.executeQuery("select *from re where username="+unt.getText()+";");
}
lusn=new JLabel("User Already Exists");
}
else{
preparedstatement.execute("insert into re values('"+nt.getText()+"','"+unt.getText()+"','"+pas.getText()+"','"+add.getText()+"','"+mail.getText()+"','"+ph.getText()+"');");
preparedstatement.executeUpdate();
}
请帮助我提前谢谢