Subject Re: [Firebird-Java] Transaction parameters + Jaybird
Author Roman Rokytskyy
> I want to use read-only read commited transaction for very long read-only
> queries and snapshot transactions for reports, but I can't find how to set
> these properties for transactions in Jaybird.
>
> Could you please show me the code example or give the link to
> manual/javadoc?

TransactionParameterBuffer tpb1 =
connection1.createTransactionParameterBuffer();

tpb1.addArgument(TransactionParameterBuffer.READ_COMMITTED);
tpb1.addArgument(TransactionParameterBuffer.REC_VERSION);
tpb1.addArgument(TransactionParameterBuffer.READ);
tpb1.addArgument(TransactionParameterBuffer.WAIT);

connection1.setTransactionParameters(tpb1);



TransactionParameterBuffer tpb2 =
connection2.createTransactionParameterBuffer();

tpb2.addArgument(TransactionParameterBuffer.CONCURRENCY);
tpb2.addArgument(TransactionParameterBuffer.WRITE);
tpb2.addArgument(TransactionParameterBuffer.WAIT);

connection2.setTransactionParameters(tpb);

Please note, if you use
setTransactionParameters(TransactionParameterBuffer tpb) method, it is
only for the next transaction with that particular isolation level, if
you want to change the TPB mapping (which will apply for all next
transactions in the same VM with the same isolation level), you should
use "setTransactionParameters(int isolationLevel,
TransactionParameterBuffer tpb)", where isolationLevel is the constant
from java.sql.Connection interface.

Roman