Hello,
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
try {
// String id = request.getParameter("id");
String uname = request.getParameter("uname");
String pwd = request.getParameter("upwd");
String email = request.getParameter("uemailId");
String country = request.getParameter("ucountry");
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url, "root", "root");
// PreparedStatement pst =(PreparedStatement) conn.prepareStatement("insert into untitled (id,fname,lastname) values ('2','naval','hedau')");
String sql = "insert into user_reg_ml (id,uname,pwd,email,country) values (?,?,?,?,?)";
PreparedStatement pst = conn.prepareStatement(sql);
pst.setString(1, "13");
pst.setString(2, uname);
pst.setString(3, pwd);
pst.setString(4, email);
pst.setString(5, country);
int i = pst.executeUpdate();
String msg = "";
if (i != 0) {
//msg = "Record has been inserted";
//pw.print("" + msg + "");
HttpSession sess = request.getSession();
sess.setAttribute("uname", request.getParameter("uname"));
sess.setAttribute("pwd", request.getParameter("cpwd"));
RequestDispatcher dispatcher = request.getRequestDispatcher("/mypage1.jsp");
dispatcher.forward(request, response);
File dir = new File("D:\\nameoffolder\\" + uname);
dir.mkdir();
} else {
msg = "failed to insert the data";
pw.print("" + msg + "");
}
pst.close();
} catch (Exception e) {
pw.println(e);
}
processRequest(request, response);
here i want the id values to get incremented automatically, I have altered the table and made the value to autoincrement, also passed null values but it ain't working.