Question: I have a background thread that is querying an Oracle database via a Select statement. The statement is populating a ResultSet Java object. If the query returns a lot of rows, the ResultSet object might get very large. If it's too large, I want to both cancel the background thread, but more importantly I want to cancel the thread that is creating the ResultSet object and eating up a lot of Java memory.

From what I have read so far online, `java.sql.Statement cancel()`, seems to be the best way to get this done, can anyone confirm this? is there a better way?

`java.sql.Statement close()` also works, I could probably catch the ExhaustedResultset exception, but maybe that's not safe.

To clarify, I do not want the ResultSet or the thread - I want to discard both completely from memory.

Answer: 
Ok actually it was my own mistake and I feel incredibly dumb now.

I was actually removing the right item but in each view I was replacing each item at *position* with what was there in the first place. So each item was the correct one but the picture/text were the old one because I was modifying them inside *getView()*.

Sorry for that lose of time, my bad, I want to punch myself now.
Please use 

```
  holder.close.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View arg1)
        {
            // list.remove(position);
            list.remove(position);              
            adapter.notifyDataSetChanged();
        }
    });

```

instead of close.setOnClickListener, i ran your this code an now it work fine