use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.
the class TestFBTpbMapper method testNewWithMappingFile.
@Test
public void testNewWithMappingFile() throws Exception {
FBTpbMapper mapper = new FBTpbMapper(TEST_TPB_MAPPING, getClass().getClassLoader());
TransactionParameterBuffer tpbValue = mapper.getMapping(Connection.TRANSACTION_READ_COMMITTED);
assertTrue("READ_COMMITTED must be isc_tpb_read_committed+isc_tpb_no_rec_version+isc_tpb_write+isc_tpb_nowait", tpbValue.size() == 4 && tpbValue.hasArgument(ISCConstants.isc_tpb_read_committed) && tpbValue.hasArgument(ISCConstants.isc_tpb_no_rec_version) && tpbValue.hasArgument(ISCConstants.isc_tpb_write) && tpbValue.hasArgument(ISCConstants.isc_tpb_nowait));
tpbValue = mapper.getMapping(Connection.TRANSACTION_REPEATABLE_READ);
assertTrue("REPEATABLE_READ must be isc_tpb_consistency+isc_tpb_write+isc_tpb_wait", tpbValue.size() == 3 && tpbValue.hasArgument(ISCConstants.isc_tpb_consistency) && tpbValue.hasArgument(ISCConstants.isc_tpb_write) && tpbValue.hasArgument(ISCConstants.isc_tpb_wait));
tpbValue = mapper.getMapping(Connection.TRANSACTION_SERIALIZABLE);
assertTrue("SERIALIZABLE must be isc_tpb_concurrency+isc_tpb_write+isc_tpb_wait", tpbValue.size() == 3 && tpbValue.hasArgument(ISCConstants.isc_tpb_concurrency) && tpbValue.hasArgument(ISCConstants.isc_tpb_write) && tpbValue.hasArgument(ISCConstants.isc_tpb_wait));
}
use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.
the class TestFBTpbMapper method testNewWithIncompleteMap_unspecifiedUseDefaults.
@Test
public void testNewWithIncompleteMap_unspecifiedUseDefaults() throws Exception {
final FBTpbMapper defaultMapper = FBTpbMapper.getDefaultMapper();
final Map<String, String> map = new HashMap<>();
map.put(FBTpbMapper.TRANSACTION_REPEATABLE_READ, "isc_tpb_concurrency,isc_tpb_write,isc_tpb_wait,isc_tpb_lock_timeout=5");
FBTpbMapper mapper = new FBTpbMapper(map);
// Check if matches specified
TransactionParameterBuffer tpbValue = mapper.getMapping(Connection.TRANSACTION_REPEATABLE_READ);
assertTrue("REPEATABLE_READ must be isc_tpb_concurrency+isc_tpb_write+isc_tpb_wait+isc_tpb_lock_timeout=5", tpbValue.size() == 4 && tpbValue.hasArgument(ISCConstants.isc_tpb_concurrency) && tpbValue.hasArgument(ISCConstants.isc_tpb_write) && tpbValue.hasArgument(ISCConstants.isc_tpb_wait) && tpbValue.hasArgument(ISCConstants.isc_tpb_lock_timeout) && tpbValue.getArgumentAsInt(ISCConstants.isc_tpb_lock_timeout) == 5);
// Check other isolation levels match default:
assertEquals(defaultMapper.getMapping(Connection.TRANSACTION_SERIALIZABLE), mapper.getMapping(Connection.TRANSACTION_SERIALIZABLE));
assertEquals(defaultMapper.getMapping(Connection.TRANSACTION_SERIALIZABLE), mapper.getMapping(Connection.TRANSACTION_SERIALIZABLE));
}
use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.
the class TestV10EventHandling method getTransaction.
private FbTransaction getTransaction(FbDatabase db) throws SQLException {
TransactionParameterBuffer tpb = new TransactionParameterBufferImpl();
tpb.addArgument(ISCConstants.isc_tpb_read_committed);
tpb.addArgument(ISCConstants.isc_tpb_rec_version);
tpb.addArgument(ISCConstants.isc_tpb_write);
tpb.addArgument(ISCConstants.isc_tpb_wait);
return db.startTransaction(tpb);
}
use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.
the class TestJnaEvents method getTransaction.
private FbTransaction getTransaction(FbDatabase db) throws SQLException {
TransactionParameterBuffer tpb = new TransactionParameterBufferImpl();
tpb.addArgument(ISCConstants.isc_tpb_read_committed);
tpb.addArgument(ISCConstants.isc_tpb_rec_version);
tpb.addArgument(ISCConstants.isc_tpb_write);
tpb.addArgument(ISCConstants.isc_tpb_wait);
return db.startTransaction(tpb);
}
use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.
the class FBTpbMapper method processMapping.
/**
* Process specified string mapping. This method updates default mapping
* with values specified in a <code>stringMapping</code>.
*
* @param stringMapping
* mapping to process.
* @throws FBResourceException
* if mapping contains incorrect values.
*/
private void processMapping(Map<String, String> stringMapping) throws FBResourceException {
for (Map.Entry<String, String> entry : stringMapping.entrySet()) {
String jdbcTxIsolation = entry.getKey();
Integer isolationLevel;
try {
isolationLevel = getTransactionIsolationLevel(jdbcTxIsolation);
} catch (IllegalArgumentException ex) {
throw new FBResourceException("Transaction isolation " + jdbcTxIsolation + " is not supported.");
}
TransactionParameterBuffer tpb = processMapping(entry.getValue());
mapping.put(isolationLevel, tpb);
}
}
Aggregations