判断用户是否在数据库内错误了?
代码如下
ResultSet rs = stmt.executeQuery("select count(*) from ZCXX z where z.yonghuming = '"+users+"'");
if(rs.next()){
flag=true;
}
if (!flag){
stmt.execute("insert into ZCXX(YONGHUMING,XINGMING,XINGBIE,SHENGRI,MIMA,ZCRQ) values('"+ users+ "','"+ name+ "','"+ sex+ "','"+ shengri+ "','" + pwds + "','" + str_date1 + "')");
out.print("<br/><br/><br/><center><H1>注册成功 ! <H1> </center> ");
}
else{
out.print("<br/><br/><br/><center><H1>用户名已存在!<H1> </center>");
}
无论我输入什么 他都OUTPRINT 用户名已存在!<
------解决方案--------------------就算没有,count(*)出来也是0喽...
flag自然一直都是true了...
------解决方案--------------------count(*)改成 *
------解决方案--------------------sql文改成试试
select * from ZCXX z where z.yonghuming = '"+users+"';