importjava.io.*;importjava.sql.*;importjavax.servlet.*;importjavax.servlet.http.*;publicclassUserInfoDBextendsHttpServlet{publicUserInfoDB(){super();}publicvoidinit()thro...
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class UserInfoDB extends HttpServlet
{
public UserInfoDB()
{
super();
}
public void init() throws ServletException {}
public void process(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html;charset=UTF-8");
PrintWriter pw=res.getWriter();
try {
// 接收用户注册信息
String u = req.getParameter("username");
String p = req.getParameter("passwd");
String e = req.getParameter("Email");
//ps = ct.prepareStatement("insert into users(username,passwd,email) values(u,p,e)");
pw.println("");
pw.println("
");pw.println("
pw.println("
恭喜"+u+"注册成功!");pw.println("
请返回登录!");pw.println("
");pw.println("");
pw.println("");
// 得到连接
ConnDB cd = new ConnDB();
Connection ct = cd.getConn();
Statement st = ct.createStatement();
st.execute("insert users(username,passwd) values('AAA',99)");
//String sqlstr ="insert into users(username,passwd,email) values(u,p,e)";
//sm.executeUpdate(sqlstr);
//pw.println(sqlstr);
//boolean bl= sm.execute("insert into users(username,passwd,email) values(u,p,e)");
// if(bl)
//{res.sendRedirect("Register");}
// else {
// 说明用户名不存在
//res.sendRedirect("Home");
st.close();
ct.close(); }
catch (Exception ex)
{
ex.printStackTrace();
}
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
process(req, res);
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
process(req, res);
}
public void destroy()
{
}
}
加上 into 也不行。谢谢了
有包的
展开