Option 1:
Use a custom transaction parameter buffer and put the transaction number
in with TpbItems.isc_tpb_at_snapshot_number (available in Jaybird 5 and
higher).
See also
https://firebirdsql.github.io/jaybird-manual/jaybird_manual.html#transactions-tpb
Compared to the example linked, use something like:
```
long snapshotNumber = ... // obtained elsewhere
tpb.addArgument(TpbItems.isc_tpb_concurrency);
tpb.addArgument(TpbItems.isc_tpb_write);
tpb.addArgument(TpbItems.isc_tpb_at_snapshot_number, snapshotNumber);
tpb.addArgument(TpbItems.isc_tpb_wait);
tpb.addArgument(TpbItems.isc_tpb_lock_timeout, 15);
```
If you use Jaybird 4 or earlier (which you shouldn't ;), then you can use
```
tpb.addArgument(23, snapshotNumber);
```
23 is the value of isc_tpb_at_snapshot_number. In Jaybird 4 and earlier,
the other constants are defined in ISCConstants (TpbItems doesn't exist
yet).
Option 2:
Use Jaybird 6, and add connection property allowTxStmts=true and execute
SET TRANSACTION with auto-commit disabled and no active transaction. If
you do have an active transaction, you must call Connection#commit()
before executing SET TRANSACTION.
See also
https://firebirdsql.github.io/jaybird-manual/jaybird_manual.html#ref-allowtxstmts
For example:
```
long snapshotNumber = ... // obtained elsewhere
try (var connection =
DriverManager.getConnection("jdbc:firebird:///employee?allowTxStmts=true",
"sysdba", "masterkey";
var stmt = connection.createStatement()) {
connection.setAutoCommit(false);
// Start a transaction with the desired snapshot
stmt.execute("set transaction snapshot at number " + snapshotNumber);
// do stuff
// commit as normal
connection.commit();
}
```
Mark
--
Mark Rotteveel