Subject | Re: [Firebird-Java] Transaction parameters + Jaybird |
---|---|
Author | Roman Rokytskyy |
Post date | 2010-04-22T09:24:15Z |
> I want to use read-only read commited transaction for very long read-onlyTransactionParameterBuffer tpb1 =
> 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?
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