下面的sql语句怎么写才能让 pstmt.executeQuery();返回一个int类型,判断数据库里是否有这条记录
Stringsql="selectcount(0)fromadministratorwhrename=?;pstmt=conn.prepareStatement(sql)...
String sql = "select count(0) from administrator whre name = ?;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, Name);
int count = pstmt.executeQuery();
if(count>0){
out.print(“该用户已经被注册”);
} 展开
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, Name);
int count = pstmt.executeQuery();
if(count>0){
out.print(“该用户已经被注册”);
} 展开
1个回答
展开全部
int i=0;
String sql = "select * from administrator whre name = ?;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, Name);
ResultSet re = pstmt .executeQuery();
while(re.next()){
i++;
}
if(i>0){
out.print(“该用户已经被注册”);
}
String sql = "select * from administrator whre name = ?;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, Name);
ResultSet re = pstmt .executeQuery();
while(re.next()){
i++;
}
if(i>0){
out.print(“该用户已经被注册”);
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询