Subject Jaybird 'object in use' error adding ref integrity constraint
Author Rashid Motala
Hello everyone,

Firstly, a hearty thank you to all the developers of the Jaybird driver.
It is excellent, and the development effort is much appreciated.

We are currently testing Jaybird with our app (replacing Interclient).
We use the Borland Data Express library. We had a few minor problems
with ambiguous column names in a few queries. Otherwise, almost
everything seems to work. We have now encountered this problem, with a
tool we provide for doing metadata updates in order to upgrade the
database to a new version. The tool picks ups all the scripts in a
folder, and runs them against the database in Java. This is the error,
which occurs adding a referential integrity constraint:

ALTER TABLE CARD_BARCODE ADD CONSTRAINT RefCARD_QUERY87 FOREIGN KEY
(FIELD_ID,EV_NO,CARD_ID) REFERENCES CARD_QUERY(FIELD_ID,EV_NO,CARD_ID)

And the error we get is...
java.sql.SQLException: Error during autocommit:
javax.resource.ResourceException: couldn't commit local transaction:
javax.transaction.xa.XAException: unsuccessful metadata update
object CARD_QUERY is in use
at
org.firebirdsql.jdbc.FBConnection.checkEndTransaction(FBConnection.java:
921)
at
org.firebirdsql.jdbc.FBPreparedStatement.execute(FBPreparedStatement.jav
a:421)

Running this from IBConsole works. Any ideas? Oh yes, we have created a
new database (dialect 3) and this didn't make any difference. Also tried
running this in another session (reboot/shutdown/new database etc)...

We do not use JBOSS or connection pooling or anything like that - just
straight JDBC (replacing interclient).

Regards,
Rashid Motala <rashidm@...>
Impro Technologies
South Africa