drasya_zura

Untitled

Mar 15th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. addtrainee.jsp
  2. <%--
  3. Document : addtrainee
  4. Created on : Mar 14, 2017, 4:12:58 PM
  5. Author : Lenovo
  6. --%>
  7. <%@page import = "java.sql.Connection"%>
  8. <%@page import = "java.sql.DriverManager"%>
  9. <%@page import = "java.sql.Statement"%>
  10. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  11.  
  12. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  13. <html>
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  16. <title>ADD TRAINEE</title>
  17. </head>
  18. <body>
  19. <%
  20. Connection conn = null;
  21. try
  22. {
  23. Class.forName("org.gjt.mm.mysql.Driver");
  24. String url = "jdbc:mysql://localhost/traineemanagementsystem";
  25. String user = "root";
  26. String pwd = "";
  27. conn = DriverManager.getConnection(url,user,pwd);
  28. Statement s = conn.createStatement();
  29. String name = request.getParameter("traineeNAME");
  30. String city = request.getParameter("traineeCITY");
  31. String query = "INSERT INTO trainee"
  32. + "(traineeNAME, traineeCITY)"+ "VALUES"
  33. + "'('" + name+ "', '" + city+"')'";
  34. int i = s.executeUpdate(query);
  35.  
  36. if(i==1)
  37. System.out.println("TRAINEE RECORDED");
  38. else
  39. System.out.println("TRAINEE NOT RECORDED");
  40.  
  41. if(conn!=null)
  42. conn.close();
  43. }
  44. catch (Exception e){response.sendError(HttpServletResponse.SC_NOT_FOUND);}
  45.  
  46. finally
  47. {
  48. if(null != conn)
  49. {conn.close();}
  50. }
  51. %>
  52. <h1>New Trainee Successfully Inserted!!!</h1>
  53. <br>
  54. <a href=traineeForm.html>Add New Trainee</a>
  55. <a href=traineeReport.jsp>List Of Trainee</a>
  56.  
  57. </body>
  58. </html>
Add Comment
Please, Sign In to add comment