Subject Re: Problem with multi-threaded update/query
Author Roman Rokytskyy

> > 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)?
> If they are sharing a single connection, then yes, you need to be
> synchronized. If each thread has its own connection, there is no
> synchornization requirement.
> You must however make sure that only one thread within your
> application is attempting to create a single connection component at a
> time.

That is not 100% correct. The JDBC specification requires that the
driver itself does the synchronization, so in Java application does
not need to do anything special - they can use one connection per
thread as well as share a connection between all threads. Naturally,
one has to consider the fact that there can be only one transaction
per connection, so if one shares the connection, he has to have a
policy for transaction management - who and when commits - otherwise
the behavior will be unpredictable.

As to the specified error - I need a test case to reproduce it. It
should never happen, though I know that Jaybird versions 1.0.x and
1.5.x had some problems there. I have reworked the underlying code in
2.x, but it may be that something was not fixed.

The NullPointerException is even worser - it should never happen.

Therefore, please join the Firebird-Java list and post there at least
the stack traces, preferably with a test case. And I need exact
Jaybird version too.