Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws
- IOException {
- resp.setContentType("text/html");
- PrintWriter out = resp.getWriter();
- String email = req.getParameter("email");
- String userName = req.getParameter("username");
- String pass = req.getParameter("password");
- if(!email.isEmpty() && !userName.isEmpty() && !pass.isEmpty()){
- out.println("Welcome n" + userName + "t" +email + "t" +pass);
- String publicKey = "";
- String privateKey = "";
- try {
- publicKey = generateKeys.generatePublic();
- privateKey = generateKeys.generatePrivate();
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- }
- mySql.sqlInsert(userName, pass, publicKey, privateKey);
- boolean ans =mySql.validUser(userName);
- out.print(ans);
- }
- else{
- out.println("Please fill in all the Fields");
- }
- public static void sqlInsert(String name, String pass, String publicKey,
- String privateKey) {
- // String msg;
- String sql;
- try {
- sql = "INSERT INTO users (uName,password, publicKey,privateKey) VALUES(?,?,?,?)";
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/c_schema?autoReconnect=true&useSSL=false", "root", "");
- PreparedStatement stm = con.prepareStatement(sql);
- stm.setString(1, name);
- stm.setString(2, pass);
- stm.setString(3, publicKey);
- stm.setString(4, privateKey);
- stm.executeUpdate();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
Add Comment
Please, Sign In to add comment