Subject Re: object tablename is in use
Author Roman Rokytskyy
Hi,

> I am trying to drop a table in Java and am having trouble with
> object tablename is in use message.
>
> Using:
> con.setAutoCommit(false);
> statement.executeUpdate("DROP TABLE tablename");
> con.commit();
> con.setAutoCommit(false);
>
> fails on the commit with the message 'object tablename is in use'.
>
> What exactly puts a table 'in use'

Any open connection in which you have open statement that directly or
indirectly references this table. If you use connection pooling from
JayBird you have to disable statement pooling to be sure that closing
the connection will actually happen.

> and what code do you use to take
> it 'out of use'.

Close all connections to the database (not only all connections in
your application), open a new one, drop the table, commit. It is
always a good practice to do metadata changes when nobody is connected
to the database.

Roman