Guest User

Untitled

a guest
Dec 7th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.50 KB | None | 0 0
  1. <%@page language="java" import="java.sql.*,java.util.*"%>
  2.  
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. </head>
  7. <body>
  8.  
  9. <%
  10. Driver DriverRecordset1 = (Driver) Class.forName("org.postgresql.Driver").newInstance();
  11. Properties props = new Properties();
  12. props.setProperty("user", "postgres");
  13. props.setProperty("password", "123456");
  14. String url = "jdbc:postgresql://localhost/projectdb";
  15. Connection Conn = DriverManager.getConnection(url, props);
  16.  
  17. //Create a dropdown menu of all restaurants
  18. Statement st = Conn.createStatement();
  19. ResultSet rs = st.executeQuery("select res_name from Restaurant");
  20. HttpSession sess = request.getSession(true);
  21. String query = "select * from restaurant";
  22. sess.setAttribute("query", query);
  23. %>
  24.  
  25.  
  26. <div align="center">
  27. <table border="1" cellpadding="5">
  28. <caption><h2>Queries</h2></caption>
  29.  
  30.  
  31. <tr>
  32. <td>Find restaurants that have a review with taste, delivery, and customer service ratings greater than
  33. <form name="f0" action="server.jsp" >
  34. <select>
  35. <% for(int i = 0; i < 5; i++){ %>
  36. <option><%= i%></option>
  37. <% } %>
  38. </select>
  39.  
  40. <input type="submit" name="submit" value="submit">
  41. </form>
  42. </td>
  43. </tr>
  44.  
  45. <tr>
  46. <td>Find restaurants with more than
  47. <form name="f1" action="server.jsp" >
  48. <select>
  49. <% rs = st.executeQuery("select max(x.num) as y from (select count(*) as num from review group by res_id) as x");
  50. rs.next();
  51. for(int i = 0; i <= rs.getInt("y"); i++){ %>
  52. <option><%= i%></option>
  53. <% } %>
  54. </select>
  55. reviews
  56.  
  57. <input type="submit" name = "submit" value="submit">
  58. </form>
  59. </td>
  60. </tr>
  61.  
  62. <tr>
  63. <td>Find users who've spent more than
  64. <form name="f2" action="server.jsp" >
  65. <input type="text" name="dollars" min=0 size=4>
  66. dollars on a single order.
  67.  
  68. <input type="submit" name = "submit" value="submit">
  69. </form>
  70. </td>
  71. </tr>
  72.  
  73. <tr>
  74. <td>Find customers who have eaten in at least
  75. <form name="f3" action="server.jsp" >
  76. <select>
  77. <% rs = st.executeQuery("select count(*) as y from restaurant");
  78. rs.next();
  79. for(int i = 0; i <= rs.getInt("y"); i++){ %>
  80. <option><%= i%></option>
  81. <% } %>
  82. </select>
  83. restaurants
  84.  
  85. <input type="submit" name = "submit" value="submit">
  86. </form>
  87. </td>
  88. </tr>
  89.  
  90. <tr>
  91. <td>Find customers who have only eaten at restaurants that serve
  92. <form name="f4" action="server.jsp" >
  93. <select>
  94. <% rs = st.executeQuery("select distinct dish_name as y from dish");
  95. rs.next();
  96. while (rs.next()){ %>
  97. <option><%= rs.getString("y")%></option>
  98. <% } %>
  99. </select>
  100.  
  101. <input type="submit" name = "submit" value="submit">
  102. </form>
  103. </td>
  104. </tr>
  105.  
  106. <tr>
  107. <td>Find dishes that cost less than
  108. <form name="f5" action="server.jsp" >
  109. <input type="text" name="dollars" min=0 size=4>
  110. dollars
  111.  
  112. <input type="submit" name = "submit" value="submit">
  113. </form>
  114. </td>
  115. </tr>
  116.  
  117. <tr>
  118. <td>Find all customers who've ordered
  119. <form name="f6" action="server.jsp" >
  120. <select>
  121. <% rs = st.executeQuery("select distinct dish_name as y from dish");
  122. rs.next();
  123. while (rs.next()){ %>
  124. <option><%= rs.getString("y")%></option>
  125. <% } %>
  126. </select>
  127. in every order.
  128.  
  129. <input type="submit" name = "submit" value="submit">
  130. </form>
  131. </td>
  132. </tr>
  133.  
  134. <tr>
  135. <td>Find dishes with a wait time of less than
  136. <form name="f7" action="server.jsp" >
  137. <input type="text" name="dollars" min=0 size=4>
  138. minutes
  139.  
  140. <input type="submit" name = "submit" value="submit">
  141. </form>
  142. </td>
  143. </tr>
  144.  
  145. <tr>
  146. <td>Find customers who did not get discounts in all orders made between
  147. <form name="f8" action="server.jsp" >
  148.  
  149. <input type="date" name="day1">
  150. and
  151. <input type="date" name="day2">
  152.  
  153. <input type="submit" name="submit" value="submit" onclick="myFunction()">
  154. </form>
  155. </td>
  156. </tr>
  157.  
  158. </table>
  159.  
  160. </div>
  161. </body>
  162. </html>
Add Comment
Please, Sign In to add comment