title: Retrieving a large result set in MySQL without affecting speed
body: <p>In my application i have result set containing more than 20000 rows. I want to save it to an Array List. I am using the below code for this.</p>
  
  <pre><code>Class.forName("com.mysql.jdbc.Driver") ;
  Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Data",     "root", "root") ;
    Statement stmt = conn.createStatement() ;
    String query = "select * from temp ;" ;
    ResultSet rs = stmt.executeQuery(query) ;
  
    ArrayList&lt;String&gt; varList = new ArrayList&lt;String&gt;();
    while(rs.next()){
    varList.add(rs.getString(1));
    }
  </code></pre>
  
  <p>When i use the query it takes more time to fetch the data from the resultset and too slow if the table contains more than 20000 entries. How can this be solved ? Any suggestions will be very greatful.</p>