import java.sql.SQLException;
import java.sql.Statement;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.DriverManager;
import java.sql.DatabaseMetaData;
import java.util.*;
import java.io.*;

public class bug8487 {

    protected static String dbUrl = "jdbc:mysql:///test?";
    protected static Connection conn = null;
    protected static ResultSet rs = null;
    protected static PreparedStatement cstmt = null;

    public static void createTable() throws Exception
    {
        Statement stmt = conn.createStatement();
        stmt.executeUpdate("drop table if exists tablea");
        stmt.executeUpdate("create table tablea (a char(10), b char(10), c char(10))");
        stmt.executeUpdate("insert into tablea values('1','2','3')");
        stmt.executeUpdate("insert into tablea values('4','5','6')");
          
  
    }

    public static void main(String[] args) throws Exception {

        Class.forName("com.mysql.jdbc.Driver").newInstance();

        conn = DriverManager.getConnection(dbUrl,"root","");

        createTable();

	PreparedStatement stmt = conn.prepareStatement(
                         "select a, b, c from tablea order by c asc",
                           ResultSet.TYPE_FORWARD_ONLY,
                           ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);  
	ResultSet rs = stmt.executeQuery();
	while(rs.next()){
		String test = rs.getString(3);
                System.out.println(test); 
	}
    }
}
