Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void processRequest(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html;charset=UTF-8");
- String process = (String) request.getParameter("process");
- String name = (String) request.getParameter("process");
- String phone=(String) request.getParameter("phone");
- String email = (String) request.getParameter("email");
- String pwd = (String) request.getParameter("pwd");
- PrintWriter out = response.getWriter();
- out.println("Hello");
- signup(out,process,name,email,phone,pwd);
- }
- private static int signup(PrintWriter out,String process,String name,String email,String phone,String pwd){
- Connection con = null;
- PreparedStatement stmt = null;
- ResultSet rs = null;
- try {
- con = DriverManager.getConnection("jdbc:mysql://localhost:3306/wine", "root", "");
- out.println("Process Not Found");
- if (process == "signup") {
- String query = "INSERT INTO user(name,phone,email,password,role) VALUES(?,?,?,?,1)";
- stmt = con.prepareStatement(query);
- stmt.setString(1, name);
- stmt.setString(2, phone);
- stmt.setString(3, email);
- stmt.setString(4, pwd);
- stmt.execute();
- } else {
- out.println("Process Not Found");
- }
- } catch (SQLException e) {
- // do something appropriate with the exception, *at least*:
- out.println(e);
- e.printStackTrace();
- return 0;
- }
- return 1;
- }
- public static void main(String[] args) {
- Connection con = null;
- PreparedStatement stmt = null;
- ResultSet rs = null;
- String process = "signup";
- String name = "Test";
- String phone="45885";
- String email = "Test@gmail.com";
- String pwd = "dkjsdh";
- try {
- con = DriverManager.getConnection("jdbc:mysql://localhost:3306/wine", "root", "");
- if (process == "signup") {
- String query = "INSERT INTO user(name,phone,email,password,role,status) VALUES(?,?,?,?,1,1)";
- stmt = con.prepareStatement(query);
- stmt.setString(1, name);
- stmt.setString(2, phone);
- stmt.setString(3, email);
- stmt.setString(4, pwd);
- stmt.execute();
- } else {
- System.out.println("Process Not Found");
- }
- } catch (SQLException e) {
- // do something appropriate with the exception, *at least*:
- System.out.println(e);
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement