Guest User

Untitled

a guest
Mar 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. <%
  2. String driverName = "com.mysql.jdbc.Driver";
  3. String connectionUrl = "jdbc:mysql://localhost:3306/";
  4. String dbName = "supr";
  5. String userId = "root";
  6. String password = "secret";
  7.  
  8. try {
  9. Class.forName(driverName);
  10. } catch (ClassNotFoundException e) {
  11. e.printStackTrace();
  12. }
  13.  
  14. Connection connection = null;
  15. Statement statement = null;
  16. ResultSet resultSet = null;
  17. ResultSet resultSet2 = null;
  18. %>
  19.  
  20. <%
  21. try {
  22. connection = DriverManager.getConnection(
  23. connectionUrl + dbName, userId, password);
  24. statement = connection.createStatement();
  25. String sql = "SELECT con.container_id, con.con_location, con.con_status, concap.capacity FROM container con INNER JOIN con_capacity concap ON con.container_id = concap.container_id";
  26.  
  27. String sql2 = "SELECT p.pipe_id, p.pipe_location, pd.PipeDis_date FROM pipe p JOIN pipe_disinfect pd ON p.pipe_id = pd.pipe_id ";
  28. resultSet = statement.executeQuery(sql);
  29. resultSet2 = statement.executeQuery(sql2);
  30. %>
  31.  
  32. <table class="table table-hover">
  33. <thead>
  34. <th>Container ID</th>
  35. <th>Location</th>
  36. <th>Status</th>
  37. <th>Capacity</th>
  38. <th></th>
  39. </thead>
  40. <tbody>
  41. <%
  42. while (resultSet.next()) { %>
  43. <tr>
  44. <td><%=resultSet.getString("Container_ID")%></td>
  45. <td><%=resultSet.getString("Con_Location")%></td>
  46. <td><%=resultSet.getString("Con_Status")%></td>
  47. <td><%=resultSet.getString("Capacity")%></td>
  48. <td><button class="btn btn-primary">Schedule</button></td>
  49. </tr>
  50. </tbody>
  51. <%
  52. }
  53.  
  54. } catch (Exception e) {
  55. e.printStackTrace();
  56. }
  57. %>
  58. </table>
  59.  
  60. <table class="table table-hover">
  61. <thead>
  62. <th>Pipe ID</th>
  63. <th>Location</th>
  64. <th>Last Disinfection</th>
  65. <th></th>
  66. </thead>
  67. <tbody>
  68. <%
  69. while (resultSet2.next()) { %>
  70. <tr>
  71. <td><%=resultSet2.getString("Pipe_ID")%></td>
  72. <td><%=resultSet2.getString("Pipe_Location")%></td>
  73. <td><%=resultSet2.getString("Pipe_LastDisinfect")%></td>
  74. <td><button class="btn btn-primary">Schedule</button></td>
  75. </tr>
  76. </tbody>
  77. <% /**I'm getting an error on this line on eclipse****/
  78. }
  79.  
  80. } catch (Exception e) {
  81. e.printStackTrace();
  82. }
  83. %>
  84. </table>
Add Comment
Please, Sign In to add comment