怎样写个方法来检验用户名不存在!加个鸡毛!在线等!!!!! 怎样写个方法来检验用户名不存在!加个鸡毛!在线等!肯定要连数据库里面的表,这个方法怎么写啊!username password 00001 ******00002 ******连数据库就不要说拉就是这个检验用户名的方法啊995! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select count(id) form table where username='jordan';返回0,没有返回大于0的数字,有 public boolean execute(HttpServletRequest req) throws Exception { boolean flag = false; if(getrequest(req)){ String sqlStr = "select UserName from [admin] where UserName='00001'"; //msg = sqlStr; BookBase db = new BookBase(); conn = db.getConnection(); stmt = conn.createStatement(); try { rs = stmt.executeQuery(sqlStr); if(rs.next()){ flag = false; }else{ flag= true; } } catch (SQLException e) { // TODO 自动生成 catch 块 e.printStackTrace(); }finally{ if(null!=rs) rs.close(); if(null!=stmt) stmt.close(); db.closeConnection(conn); } } return flag; } <s:action executeResult="true"/>当把返回值设置为TRUE进入死循环 关于中文乱码的问题 开发大型论坛,要求高性能、高负载,需要做些什么? 请高手帮帮忙?? 关于链接点击的问题 linux下安装mysql的问题!已经两天了,还是没有解决 【重要!】tomcat运行过一段时间就死掉了,不能服务为什么? 求问一个maven的部署问题 延时和定时发送是如何实现的?(散分) 基础面试题 怎么由tomcat manager的application list的虚拟路径知道实际目录? 急!各位,请进来帮忙看下tomcat连接access的怪问题
返回大于0的数字,有
boolean flag = false;
if(getrequest(req)){
String sqlStr = "select UserName from [admin] where UserName='00001'";
//msg = sqlStr;
BookBase db = new BookBase();
conn = db.getConnection();
stmt = conn.createStatement();
try {
rs = stmt.executeQuery(sqlStr);
if(rs.next()){
flag = false;
}else{
flag= true;
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}finally{
if(null!=rs) rs.close();
if(null!=stmt) stmt.close();
db.closeConnection(conn);
}
}
return flag;
}