title: JDBC ResultSet no results?
body: <p>Why aren't there any results for this query? Only "Movies!" is printed when i run this servlet.</p>
  
  <pre><code>import java.io.*;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import java.sql.*;
  
  public class Service extends HttpServlet {
   private static final long serialVersionUID = 1L;
  
   protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("Movies!");
  
    Connection connection = null;
    Statement statement = null;
    try {
     connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test");   
     statement = connection.createStatement();
     String query = "SELECT * FROM movies";
     ResultSet rs = statement.executeQuery(query);
     while(rs.next()) {
      out.println("result set");
      out.print(rs.getInt(1));
      out.print(rs.getString(2));
      out.print(rs.getInt(3));
      out.print(rs.getInt(4));
     }
    } catch(SQLException e) {
     e.printStackTrace();
    }
   }
  }
  </code></pre>