为什么信息不能写入数据库?bean 没问题 因为可以读取数据。请高手帮忙看看是否代码有问题。(JSP+MYSQL)
代码如下:
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page language="java" %>
<%@ page import="com.mysql.jdbc.Driver" %>
<%@ page import="java.sql.*" %>
<jsp:useBean id="ycb" scope="page" class="ycb.dbconn" />
<%
String strUserName=request.getParameter("username");
String strRealName=request.getParameter("realname");
String strUserPWD=request.getParameter("userpwd");
String strSurePWD=request.getParameter("surepwd");
String strHandTel=request.getParameter("handtel");
String strTel=request.getParameter("tel");
String strAddress=request.getParameter("address");
String strEMail=request.getParameter("email");
session.setAttribute("s",strSurePWD);
if(strUserPWD.equals((String)session.getAttribute("s")))
{
ResultSet rs = null;
Connection conn = null;
conn = ycb.getConn() ;
rs=ycb.executeSQL("insert into user(username,realname,userpwd,handtel,tel,address,email) values ('"+strUserName+"','"+strRealName+"','"+strUserPWD+"','"+strHandTel+"','"+strTel+"','"+strAddress+"','"+strEMail+"')");
response.sendRedirect("main.jsp");}
else{
out.print("<script language='javascript'>alert('密码验证错误!');history.go(-1);</script>");}
%>