com.microsoft.sqlserver.jdbc.SQLServerException: 列名 'id' 无效,急,在线等
Stringid=request.getParameter("id");Stringname=request.getParameter("name");Stringpas...
String id= request.getParameter("id");
String name = request.getParameter("name");
String password = request.getParameter("password");
String sex = request.getParameter("sex");
String email=request.getParameter("email");
String tel=request.getParameter("tel");
Connection conn= getConnection();
PreparedStatement ps= null;
ResultSet rs = null;
String sql1= "SELECT * FROM users WHERE id=?";
ps = conn.prepareStatement(sql1);
ps.setString(1,id);
rs = ps.executeQuery();
if(rs.next()){
out.println("<center><h2>对不起,该名字用户已经存在!<a href='register.jsp'>请重新注册.</a></h2></center>");
}
else{
String sql="INSERT INTO users(id,name,pwd,sex,email,tel) VALUES(?,?,?,?,?,?)";
ps= conn.prepareStatement(sql);
ps.setString(1,id);
ps.setString(2,name);
ps.setString(3,password);
ps.setString(4,sex);
ps.setString(5, email);
ps.setString(6, tel);
ps.executeUpdate();
out.println("<center><h2><a href='index.jsp'>创建成功</a></h2></center>");}
ps.close();
conn.close();
运行时出现了 列名 'id' 无效的错误;但是SELECT * FROM users WHERE id=?这句话在数据库可以运行 展开
String name = request.getParameter("name");
String password = request.getParameter("password");
String sex = request.getParameter("sex");
String email=request.getParameter("email");
String tel=request.getParameter("tel");
Connection conn= getConnection();
PreparedStatement ps= null;
ResultSet rs = null;
String sql1= "SELECT * FROM users WHERE id=?";
ps = conn.prepareStatement(sql1);
ps.setString(1,id);
rs = ps.executeQuery();
if(rs.next()){
out.println("<center><h2>对不起,该名字用户已经存在!<a href='register.jsp'>请重新注册.</a></h2></center>");
}
else{
String sql="INSERT INTO users(id,name,pwd,sex,email,tel) VALUES(?,?,?,?,?,?)";
ps= conn.prepareStatement(sql);
ps.setString(1,id);
ps.setString(2,name);
ps.setString(3,password);
ps.setString(4,sex);
ps.setString(5, email);
ps.setString(6, tel);
ps.executeUpdate();
out.println("<center><h2><a href='index.jsp'>创建成功</a></h2></center>");}
ps.close();
conn.close();
运行时出现了 列名 'id' 无效的错误;但是SELECT * FROM users WHERE id=?这句话在数据库可以运行 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询