jsp tomcat mysql *SQL*語句

amrain發表於2008-01-17
其中報錯的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修改過]

相關文章