Advertisement
Guest User

Untitled

a guest
Dec 12th, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. <%@ page contentType="text/html; charset=iso-8859-1" language="java"
  2. import="java.sql.*" errorPage="" %>
  3. <%
  4. PreparedStatement stmt = null;
  5. Connection conn = null;
  6. try {
  7. //Connect to the database
  8. Class.forName("oracle.jdbc.driver.OracleDriver");
  9. String hostname = "172.16.60.13";
  10. int port = 1521;
  11. String sid = "orcl";
  12. String oracleURL = "jdbc:oracle:thin:@"+hostname+":"+port+":"+sid;
  13. String user = "E183383";
  14. String pass = "183383";
  15. conn = DriverManager.getConnection(oracleURL, user, pass);
  16.  
  17. //Create an empty new variable
  18. String message = null;
  19. String fname = request.getParameter("fname");
  20. String lname = request.getParameter("lname");
  21. String username = request.getParameter("user_id");
  22. String password = request.getParameter("password");
  23. String address = request.getParameter("Address");
  24. String phone = request.getParameter("user_phone");
  25. String category = request.getParameter("Category");
  26.  
  27. // Make the query
  28. stmt=conn.prepareStatement("insert into lb_user values(?,?,?,?,?,?,?,?)");
  29. stmt.clearParameters();
  30. stmt.setString(1,fname);
  31. stmt.setString(2,lname);
  32. stmt.setString(3,username);
  33. stmt.setString(4,password);
  34. stmt.setString(5,address);
  35. stmt.setString(6,phone);
  36. stmt.setString(7,category);
  37. stmt.setString(8,"0");
  38.  
  39. //Run the query
  40. stmt.executeUpdate();
  41. conn.commit();
  42.  
  43. out.println("<p> <b> You have been registered !</b></p>");
  44. //Close the database connection
  45. stmt.close();
  46. conn.close();
  47. } catch (SQLException ex) {
  48. out.println("<p><b> Could not be registered due to a system error. </b></p><p>" + ex.getMessage()+ "</p>");
  49. stmt.close();
  50. conn.close();
  51. }
  52. %>
  53. <html>
  54. <body>
  55. <script>
  56. alert("Your ID has been successfully created!");
  57. </script>
  58. </body>
  59. </html>
  60. <%
  61. response.setHeader("Refresh", "0;url=LogIn-User.html");%>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement