jsp tomcat mysql *SQL*语句

08-01-17 amrain
其中报错的SQL语句为:sql2="insert into [book](userName,userPassword,userEmail) values('" + userName + "','" + userPassword + "','" + userEmail +"')";

其余代码:(谢谢你们,新年快乐!)

<%!

String userName=null;

String userPassword=null;

String userEmail=null;

String sql2=null;

String msg=null;

boolean a=false;

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);

[该贴被amrain于2008-01-17 16:54修改过]

amrain
2008-01-17 17:41
问题已解决,由于我没有把数据库打开.谢谢那些还没有来得及为我解答的朋友.谢谢!

猜你喜欢