Guest User

Untitled

a guest
May 24th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <%@ page import="java.sql.*" %>
  2. <%@ page import="java.io.*" %>
  3.  
  4. <%
  5. String url = "jdbc:mysql://localhost:3306/bigul";
  6. String userid = "root";
  7. String pass = "root";
  8.  
  9. String name = request.getParameter("name");
  10. String user = request.getParameter("user");
  11. String password = request.getParameter("pass");
  12.  
  13.  
  14. PreparedStatement pstmt = null;
  15. try {
  16. Class.forName("com.mysql.jdbc.Driver");
  17. }
  18. catch(java.lang.ClassNotFoundException e)
  19. { System.err.print("ClassNotFoundException: " + e.getMessage()); }
  20.  
  21.  
  22. int updateQuery = 0;
  23.  
  24.  
  25. if(name != null && user != null && password != null)
  26. {
  27. try
  28. {
  29. Connection conn = DriverManager.getConnection(url,userid,pass);
  30. String queryString = "INSERT INTO info(Name,Username,Password) VALUES (?, ?, ?)";
  31. pstmt = conn.prepareStatement(queryString);
  32. pstmt.setString(1,name);
  33. pstmt.setString(2,user);
  34. pstmt.setString(3,password);
  35. updateQuery = pstmt.executeUpdate();
  36. pstmt.close();
  37. conn.close();
  38. }
  39. catch(Exception e){
  40. System.out.println(e.getMessage());
  41. }
  42.  
  43.  
  44. }
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. %>
Add Comment
Please, Sign In to add comment