0

I'm working on an Android App where the user sends queries to a database and the tuples are displayed in a Gridview.

Below you can see the code of the function where the query is executed and the tuples are retrieved. The returned ArrayList is used in the Adapter of the GridView to be displayed.

public ArrayList<String> getTuples(String query){
    String z;
    String tmp;
    ArrayList<String> tuples= new ArrayList<String>();
    try {
        Connection con = this.CONN();
        if (con == null) {
            z = "Please check your internet connection";
        } else {
            Statement stmt = con.createStatement();               
            ResultSet rs = stmt.executeQuery(query);
            while(rs.next()){
                tmp = rs.getString(1);
                tuples.add(tmp);
            }
        }
    }
    catch (Exception ex){
        z = "Exceptions"+ex;
    }
    return tuples;
}

First all tuples must be retrieved, ResultSet rs = stmt.executeQuery(query);, and then displayed.

The problem is that, because the tables consist of 300K - 800K tuples, some queries (e.g. the JOIN of two tables) take a lot of time.

Is there a way to display each tuple ON THE FLY (as soon as it arrives ) ?

Thanks a lot.

Fizz
  • 3,427
  • 4
  • 27
  • 43
nickkard
  • 11
  • 3

0 Answers0