Hello,
i query data from database using jdbc, and there will be a lot of data.how can i solve 1 by 1 of the data?currently, my code just solve the last data.
this is the pseudo:

JDBC connection
  query data = ResultSet{userid,task_id}
  while (Resultset())
    userid, task_id
    count++
    end
  close ResultSet
end

for i<=count
  solve the task
end

i know something is wrong.do i need an array?what else instead of array?

You need to create task objects when you are iterating over the resultset. These task objects can be then pushed inside a list. You can then use this list as you see fit i.e. to run the tasks etc.

// untested pseudocode
final ResultSet rs = stmt.executeQuery();
while(rs.next()) {
  // create new task object
  taskList.add(task);
}
// close resultset, statement and connection

// somewhere else
for(Task task : tasklist) {
  // execute task
}