Subject Re: [Firebird-Java] Can you use PreparedStatements together with connection pooling?
Author Roman Rokytskyy
>> In theory it should work to some extent. JDBC specification requires
>> every driver to support multithreaded access to one connection. This is
>> also implemented in Jaybird, but there were also reports of some
>> NullPointerExceptions under heavy load, which might be related to the
>> multithreaded access (though none of these issues can be reproduced
>> under normal load, so most likely many factors are responsible for that).
>
> I recently looked at that piece of code to see if I could reproduce it. I haven't been able yet, but the synchronisation there looks iffy (especially because for some classes the getSynchronisationObject() returns a new object on every call (if the connection is autocommit I believe).

In general the getSynchronizationObject() was supposed to return
Connection object in auto-commit case and something else for
non-autocommit case ("this", usually). The access to the GDSHelper (and
thus underlying implementation of GDS API) should be always synchronized
anyway.

Roman