Advertisement
drasya_zura

Untitled

Mar 15th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. traineeReport.jsp
  2. <%--
  3. Document : traineeReport
  4. Created on : Mar 14, 2017, 4:36:19 PM
  5. Author : Lenovo
  6. --%>
  7.  
  8. <%--
  9. Document : addtrainee
  10. Created on : Mar 14, 2017, 4:12:58 PM
  11. Author : Lenovo
  12. --%>
  13. <%@page import = "java.sql.Connection"%>
  14. <%@page import = "java.sql.DriverManager"%>
  15. <%@page import = "java.sql.Statement"%>
  16. <%@page import = "java.sql.ResultSet"%>
  17. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  18.  
  19. <!DOCTYPE html>
  20. <html>
  21. <head>
  22. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  23. <title>LIST OF TRAINEE</title>
  24. <h1>LIST OF TRAINEE</h1>
  25. </head>
  26. <body>
  27. <%
  28. Connection conn = null;
  29. try
  30. {
  31. Class.forName("org.gjt.mm.mysql.Driver");
  32. String url = "jdbc:mysql://localhost/traineemanagementsystem";
  33. String user = "root";
  34. String pwd = "";
  35. conn = DriverManager.getConnection(url,user,pwd);
  36. Statement s = conn.createStatement();
  37.  
  38. String query = "SELECT * FROM trainee";
  39. ResultSet res = s.executeQuery(query);
  40.  
  41. while(res.next())
  42. {
  43. int empID = res.getInt("employeeID");
  44. String name = res.getString("traineeNAME");
  45. String city = res.getString("traineeCITY");
  46. out.println(empID+" "+name+" "+city+"<br>");
  47. }
  48. if(conn!=null)
  49. conn.close();
  50. }
  51. catch (Exception e){response.sendError(HttpServletResponse.SC_NOT_FOUND);}
  52.  
  53. finally
  54. {
  55. if(null != conn)
  56. {conn.close();}
  57. }
  58. %>
  59.  
  60. <a href=traineeForm.html>Add New Trainee</a>
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement