[求助] 一段JSP小程序
<%@ page contentType="text/html; charset=GBK" import="java.sql.*" %><%
try
{
String name = request.getParameter("name");
boolean sex = (boolean)request.getParameter("sex"); //这里为什么会出错
String pwd = request.getParameter("pwd");
String pwd1 = request.getParameter("pwd1");
String question = request.getParameter("question");
String answer = request.getParameter("answer");
String email = request.getParameter("email");
Class.forName("sun.jdbc.odbc.jdbcodbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:bbs");
PreparedStatement state = conn.prepareStatement("insert usr values(?,?,?,?,?,?,?)");
state.setString(1,name);
state.setBoolean(2,sex);
state.setString(3,pwd);
state.setString(4,pwd1);
state.setString(5,question);
state.setString(6,answer);
state.setString(7,email);
ResultSet rs = state.executeUpdate(); //这里为什么会出错
if(rs.next())
out.println("<h3 align=\"center\">注册成功!</h3>");
else
out.println("<h3 align=\"center\">注册失败!<a href=\"register.html\">返回</a></h3>");
rs.close();
state.close();
conn.close();
}
catch(Exception ex)
{
out.println(ex.toString());
}
%>