如何使用servlet在mysql数据库中插入全名?例如-viraj sharma

时间:2018-08-29 17:14:27

标签: java mysql jsp servlets

我的代码是

 @Override
 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
   PrintWriter out = resp.getWriter();
   try {

    Class.forName("com.mysql.jdbc.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/patient", "root", "");
    PreparedStatement ps = con.prepareStatement("insert into userdetails(userType) VALUES(?)");
    ps.setString(1, req.getParameter("userType"));

    int b = ps.executeUpdate();
    if (b > 0)
     out.print("succes");
    else
     out.print("fail");
   }

当我运行该程序时,它仅插入全名,即viraj 并且我想存储viraj Sharma

0 个答案:

没有答案
相关问题