Subject Problem with multi-threaded update/query
Author phil_hhn
Hi, we have some code that is performing a few updates to various
tables, and takes a few seconds. The JDBC connection is not in
auto-commit; we commit when it's all finished (or rollback if there's
an error).
At the same time we have a background thread running which
periodically runs "select max(myColumn) from myWaitingMessages" (on
the same database connection), where myWaitingMessages is NOT one
involved in the update process (as described above). Sometimes an
error occurs, but it seems to be timing related and the error varies.
Sometimes it's a NullPointerException, or in some cases "GDS
Exception. 335544332. invalid transaction handle (expecting explicit
transaction start"... but always within the JDBC driver.

Can anyone tell me - do the queries in both the threads need to be
synchronized, or is the correct way to do this actually to create a
second connection to the database (for the second thread to use)?