Advertisement
Guest User

Untitled

a guest
May 3rd, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.07 KB | None | 0 0
  1.     <head>
  2.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  3.         <title>Reachable Results</title>
  4.         <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  5.     </head>
  6.     <body>
  7.    
  8.  
  9.     <p>
  10.         <button onclick="goBack()">Go Back To Selection</button>
  11.         <script>
  12.         function goBack() {
  13.             window.history.back();
  14.         }
  15.         </script>
  16.         </p>
  17.    
  18.     <table class="table table-striped">
  19.    
  20.     <thead>
  21.         <th>Retweet Count</th>
  22.         <th>Tweet Text</th>
  23.         <th>Tweet Poster</th>
  24.         <th>Category</th>
  25.         <th>Subcategory</th>
  26.         <th></th>
  27.     </thead>
  28.     <tbody>
  29.    
  30.     <%
  31.     Connection connection = null;
  32.     Statement statement = null;
  33.     ResultSet rs = null;
  34.    
  35.     String dbName = "jdbc:mysql://cs363winservdb:3306/nsyens?allowPublicKeyRetrieval=true&useSSL=false";
  36.     try{
  37.         String dbUser = (String) session.getAttribute("username");
  38.         String dbPassword = (String) session.getAttribute("password");
  39.         String nodeSelection = request.getParameter("selection");
  40.         String viewAmount = request.getParameter("viewSelection");
  41.         String yearSelected = request.getParameter("yearSelection");
  42.         String monthSelected = request.getParameter("monthSelection");
  43.         connection = DriverManager.getConnection(dbName,dbUser,dbPassword);
  44.         statement = connection.createStatement();
  45.         String query = "SELECT t.retweet_count , t.tweet_text , t.posted_user , u.category, u.sub_category FROM tweets t, users u WHERE MONTH(t.created_at)='"+ monthSelected +"' AND YEAR(t.created_at)='" + yearSelected + "' AND t.posted_user=u.screen_name ORDER BY t.retweet_count DESC LIMIT " + viewAmount +";";
  46.         ResultSetMetaData rsMetaData;
  47.         String toShow;
  48.         rs = statement.executeQuery(query);
  49.         rsMetaData = rs.getMetaData();
  50.         toShow = "";
  51.        
  52.         while (rs.next()) {
  53.             out.println("<tr>");
  54.             for (int i = 0; i < rsMetaData.getColumnCount(); i++) {
  55.                 out.println("<td>" + rs.getString(i + 1) + "</td>");
  56.             }
  57.             out.println("</tr>");
  58.             }
  59.         %>
  60.        
  61.         </tbody>
  62.         </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement