J
Jonck van der Kogel
Hi,
I have a question on threads, probably very basic but I'm having a
hard time figuring it out. I've created a little test app for
experimentation on this subject.
The app shows a JTable that is filled with data from a database. The
user can change the data in the JTable wherupon the JTable passes this
data to the database. Now this part I would like to do in a different
thread, so that the UI is not slowed when communication with the
database is taking place. To do this I've created a class has a
private class that extends Thread. The run() method of this class is
then supposed to do the JDBC stuff like creating a statement and
executing the update.
However, here I have a problem. The run() method cannot throw an
SQLException. I would like the exception to be thrown rather than
caught in the run() method, so that I can deal with the exception in
my main thread and have the UI respond accordingly (meaning: do not
update the tableModel with the newly entered value).
Does anyone have any suggestions for me how I could implement this in
a different fashion? The aim is to get the JDBC stuff to run in a
different thread than the UI does.
Thanks very much, Jonck
I have a question on threads, probably very basic but I'm having a
hard time figuring it out. I've created a little test app for
experimentation on this subject.
The app shows a JTable that is filled with data from a database. The
user can change the data in the JTable wherupon the JTable passes this
data to the database. Now this part I would like to do in a different
thread, so that the UI is not slowed when communication with the
database is taking place. To do this I've created a class has a
private class that extends Thread. The run() method of this class is
then supposed to do the JDBC stuff like creating a statement and
executing the update.
However, here I have a problem. The run() method cannot throw an
SQLException. I would like the exception to be thrown rather than
caught in the run() method, so that I can deal with the exception in
my main thread and have the UI respond accordingly (meaning: do not
update the tableModel with the newly entered value).
Does anyone have any suggestions for me how I could implement this in
a different fashion? The aim is to get the JDBC stuff to run in a
different thread than the UI does.
Thanks very much, Jonck