Search in sources :

Example 1 with TransactionParameterBuffer

use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.

the class TestFBDriver method testTransactionConfigThroughPropertiesObject.

@Test
public void testTransactionConfigThroughPropertiesObject() throws Exception {
    Properties props = getDefaultPropertiesForConnection();
    // Note that for proper testing this needs to be different from the mapping in isc_tpb_mapping.properties
    props.setProperty("TRANSACTION_READ_COMMITTED", "isc_tpb_read_committed,isc_tpb_no_rec_version,isc_tpb_write,isc_tpb_nowait");
    connection = DriverManager.getConnection(getUrl(), props);
    FirebirdConnection fbConnection = connection.unwrap(FirebirdConnection.class);
    TransactionParameterBuffer tpb = fbConnection.getTransactionParameters(Connection.TRANSACTION_READ_COMMITTED);
    assertEquals(4, tpb.size());
    assertTrue("expected isc_tpb_read_committed", tpb.hasArgument(ISCConstants.isc_tpb_read_committed));
    assertTrue("expected isc_tpb_no_rec_version", tpb.hasArgument(ISCConstants.isc_tpb_no_rec_version));
    assertTrue("expected isc_tpb_write", tpb.hasArgument(ISCConstants.isc_tpb_write));
    assertTrue("expected isc_tpb_nowait", tpb.hasArgument(ISCConstants.isc_tpb_nowait));
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) Properties(java.util.Properties) FBTestProperties(org.firebirdsql.common.FBTestProperties) Test(org.junit.Test)

Example 2 with TransactionParameterBuffer

use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.

the class TestTableReservation method prepareTPB.

protected void prepareTPB(FirebirdConnection connection, int isolationLevel, int lockMode, String tableName, int lockType, boolean readOnly) throws SQLException {
    TransactionParameterBuffer tpb = connection.createTransactionParameterBuffer();
    // specify new isolation level
    tpb.addArgument(isolationLevel);
    if (isolationLevel == TransactionParameterBuffer.READ_COMMITTED)
        tpb.addArgument(TransactionParameterBuffer.REC_VERSION);
    tpb.addArgument(!readOnly ? TransactionParameterBuffer.WRITE : TransactionParameterBuffer.READ);
    tpb.addArgument(TransactionParameterBuffer.NOWAIT);
    tpb.addArgument(lockMode, tableName);
    tpb.addArgument(lockType);
    connection.setTransactionParameters(tpb);
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer)

Example 3 with TransactionParameterBuffer

use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.

the class AbstractStatementTest method getTransaction.

private FbTransaction getTransaction() 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);
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) TransactionParameterBufferImpl(org.firebirdsql.gds.impl.TransactionParameterBufferImpl)

Example 4 with TransactionParameterBuffer

use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.

the class AbstractTransactionTest method getTransaction.

protected final FbTransaction getTransaction() 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);
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) TransactionParameterBufferImpl(org.firebirdsql.gds.impl.TransactionParameterBufferImpl)

Example 5 with TransactionParameterBuffer

use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.

the class TestFBTpbMapper method testGetMappingForREAD_UNCOMMITED_Returns_READ_COMMITTED.

@Test
public void testGetMappingForREAD_UNCOMMITED_Returns_READ_COMMITTED() {
    final FBTpbMapper defaultMapper = FBTpbMapper.getDefaultMapper();
    final TransactionParameterBuffer readCommitted = defaultMapper.getMapping(Connection.TRANSACTION_READ_COMMITTED);
    assertEquals("Expected same mapping for READ_UNCOMMITTED as for READ_COMMITTED", readCommitted, defaultMapper.getMapping(Connection.TRANSACTION_READ_UNCOMMITTED));
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) Test(org.junit.Test)

Aggregations

TransactionParameterBuffer (org.firebirdsql.gds.TransactionParameterBuffer)25 Test (org.junit.Test)12 TransactionParameterBufferImpl (org.firebirdsql.gds.impl.TransactionParameterBufferImpl)8 Properties (java.util.Properties)3 HashMap (java.util.HashMap)2 FBTestProperties (org.firebirdsql.common.FBTestProperties)2 FBResourceException (org.firebirdsql.jca.FBResourceException)2 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 FbDatabase (org.firebirdsql.gds.ng.FbDatabase)1 FbTransaction (org.firebirdsql.gds.ng.FbTransaction)1 FBManagedConnection (org.firebirdsql.jca.FBManagedConnection)1 FBConnection (org.firebirdsql.jdbc.FBConnection)1