当前位置: 代码迷 >> Java Web开发 >> Jsp注册,INSERT 语句 sql2="insert into book(userName,userPassword,userEmail) values('" + userName + "','" + userPassword + "','解决思路
  详细解决方案

Jsp注册,INSERT 语句 sql2="insert into book(userName,userPassword,userEmail) values('" + userName + "','" + userPassword + "','解决思路

热度:825   发布时间:2016-04-17 12:29:21.0
Jsp注册,INSERT 语句 sql2="insert into book(userName,userPassword,userEmail) values('" + userName + "','" + userPassword + "','
弄了好久也没弄好,刚解决一个问题,又是一个问题.麻烦得很.先谢谢你们,祝愿你们新年快乐,身体健康!
其余代码如下:
<%!
String userName=null;
String userPassword=null;
String userEmail=null;
String sql2=null;
String msg=null;
String sql1=null;
ResultSet rs=null;
%>
<jsp:useBean id="registerBean" scope="page" class="conn.Conn" />

<%
userName=new String(request.getParameter("userName").getBytes("8859_1"));
userPassword=new String(request.getParameter("userPassword").getBytes("8859_1"));
userEmail=request.getParameter("userEmail");
sql1="select * from book where userName = '" + userName + "'";
rs=registerBean.executeQuery(sql1);
if(rs.next()){
msg="sorry,the user is existed";
session.putValue("register_message",msg);

%>
<jsp:forward page="register.jsp"/>
<%
}
else{
sql2="insert into book(userName,userPassword,userEmail) values('" + userName + "','" + userPassword + "','" + userEmail +"')";

registerBean.executeUpdate(sql2);
try{

msg="welecome to you";
session.putValue("register_message",msg);
msg=null;
}catch(Exception ex){
throw new Exception("wrong2");
}
}

------解决方案--------------------
那这次报的什么错?
  相关解决方案