Reputation: 869
I would like to apply Java Concurrent i.e. Callable for resultset. The scenario is -
Since the data would be large i would like to resultset. Please help me to get better approach for the problem.
Upvotes: 1
Views: 258
Reputation: 13649
I suppose you are programming under swing or javaFX, then you are blocking the GUI thread.
So you must create another Thread to process the jdbc request, and display a 'please wait' message.
Do something like this:
new Thread(new Runnable(){
void run(){
final result = jdbc.getResultSet();
// Under JavaFX 2
Platform.runLater( new Runnable() {
public void run() {
//Show results
}
} );
// Under Swing
SwingUtilities.invokeLater(new Runnable() {
public void run() {
//Show results
}
});
}
}
);
Upvotes: 0
Reputation: 8896
Because of the way ResultSet is designed it is not supposed to be used concurrently by many threads. But you can create one thread that iterates over the result set and send row data to Callables that will perform further processing of each row (or group of rows).
Upvotes: 2