Subject Re: I need some help with Transactions
Author Roman Rokytskyy <rrokytskyy@acm.org>
> Our problem is that QueryTimeout isn't working (DOC: do nothing)
> and we neither know how to make that instead of "deadlock" we get
> an SQLExcetion or something similar.

Neither query timeout nor query cancelling are supported by server.

> We readed that setting TransactionIsolation to
> TRANSACTION_REPEATABLE_READ will trow it, but didn't work.

You need to provide custom TPB (Transaction Parameter Buffer)
mapping. When there is a lock conflict, Firebird checks the TPB is it
contains isc_tpb_wait or isc_tpb_nowait. In former case server will
wait until the lock is released. In latter case it will throw an
exception about lock conflict. isc_tpb_wait is a default value.

If you are 100% sure that your application design is correct and
getting an exception in case of lock conflict is what you want, you
must specify your custom TPB mapping in connection parameters:

Properties props = new Properties();
props.setProperty("user", "SYSDBA");
props.setProperty("password", "masterkey");
props.setProperty("TRANSACTION_REPEATABLE_READ",
"isc_tpb_write,isc_tpb_concurrency,isc_tpb_nowait");
//.. here you can specify mapping for other tx isolation levels

Connection con = DriverManager.getConnection(url, props);

Or you can include this mapping in URL as following:

jdbc:firebirdsql:....my.gdb?
TRANSACTION_REPEATABLE_READ=isc_tpb_concurrency,isc_tpb_write,isc_tpb_
nowait

But again, check first if everything is correct with your application
design. Deadlock is very often sign that something is wrong.

Best regards,
Roman Rokytskyy