Subject How do I begin a transaction to get table reservation behaviour
Author dhay@lexmark.com
Hi,

I've continued to get my head around TransactionParameterBuffer, and am now
left with a simple question.

I need table reservation, so that the table lock is initiated when the
transaction begins, not when the first statement is executed. I can do
this in isql just fine, however although I can set the correct TPB
attributes, my transaction doesn't appear to start until I executed the
first statement.

Hopefully this is not a silly question, but what's the best way to do this?
My code snippet is below...

cheers,

David

//get connection
FirebirdConnection fbConnection = getConnectionViaDriverManager();

//turn autocommit off
fbConnection.setAutoCommit(false);
System.out.println(Thread.currentThread().getId() + "fbconnection -
autocommit set to false");

//set up transaction params
TransactionParameterBuffer tpb =
fbConnection.createTransactionParameterBuffer();

//SNAPSHOT Isolation level
tpb.addArgument(TransactionParameterBuffer.CONCURRENCY);
//READ WRITE access
tpb.addArgument(TransactionParameterBuffer.WRITE);
//WAIT lock resolution
tpb.addArgument(TransactionParameterBuffer.WAIT);
//PROTECTED WRITE Reservation on PrinterGroup table
tpb.addArgument(TransactionParameterBuffer.PROTECTED);
tpb.addArgument(TransactionParameterBuffer.LOCK_WRITE,
"PRINTERGROUP");

fbConnection.setTransactionParameters(tpb);

Statement stmt = fbConnection.createStatement();

String sql = "SELECT * FROM PRINTERGROUP";

stmt.execute(sql);
//LOCK ESTABLISHED HERE!!