Search in sources :

Example 6 with TransactionParameterBufferImpl

use of org.firebirdsql.gds.impl.TransactionParameterBufferImpl in project jaybird by FirebirdSQL.

the class BaseTestBlob method getTransaction.

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

Example 7 with TransactionParameterBufferImpl

use of org.firebirdsql.gds.impl.TransactionParameterBufferImpl in project jaybird by FirebirdSQL.

the class FBTpbMapper method processMapping.

/**
 * Process comma-separated list of keywords and convert them into TPB
 * values.
 *
 * @param mapping
 *         comma-separated list of keywords.
 * @return set containing values corresponding to the specified keywords.
 * @throws SQLException
 *         if mapping contains keyword that is not a TPB parameter.
 */
public static TransactionParameterBuffer processMapping(String mapping) throws SQLException {
    // TODO instance creation should be delegated to FbDatabase
    TransactionParameterBuffer result = new TransactionParameterBufferImpl();
    StringTokenizer st = new StringTokenizer(mapping, ",");
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        Integer argValue = null;
        if (token.contains("=")) {
            String[] parts = token.split("=");
            try {
                argValue = Integer.valueOf(parts[1]);
            } catch (NumberFormatException ex) {
                // TODO More specific exception, Jaybird error code
                throw new SQLException(parts[1] + " is not valid integer value");
            }
            token = parts[0];
        }
        Integer value = ParameterBufferHelper.getTpbParam(token);
        if (value == null) {
            // TODO More specific exception, Jaybird error code
            throw new SQLException("Keyword " + token + " unknown. Please check your mapping.");
        }
        if (argValue == null) {
            result.addArgument(value);
        } else {
            result.addArgument(value, argValue);
        }
    }
    return result;
}
Also used : SQLException(java.sql.SQLException) TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) TransactionParameterBufferImpl(org.firebirdsql.gds.impl.TransactionParameterBufferImpl)

Example 8 with TransactionParameterBufferImpl

use of org.firebirdsql.gds.impl.TransactionParameterBufferImpl in project jaybird by FirebirdSQL.

the class TestJnaDatabase method getTransaction.

private FbTransaction getTransaction(FbDatabase db) throws SQLException {
    TransactionParameterBuffer tpb = new TransactionParameterBufferImpl();
    tpb.addArgument(TpbItems.isc_tpb_read_committed);
    tpb.addArgument(TpbItems.isc_tpb_rec_version);
    tpb.addArgument(TpbItems.isc_tpb_write);
    tpb.addArgument(TpbItems.isc_tpb_wait);
    return db.startTransaction(tpb);
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) TransactionParameterBufferImpl(org.firebirdsql.gds.impl.TransactionParameterBufferImpl)

Example 9 with TransactionParameterBufferImpl

use of org.firebirdsql.gds.impl.TransactionParameterBufferImpl in project jaybird by FirebirdSQL.

the class TestV10Database 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);
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) TransactionParameterBufferImpl(org.firebirdsql.gds.impl.TransactionParameterBufferImpl)

Example 10 with TransactionParameterBufferImpl

use of org.firebirdsql.gds.impl.TransactionParameterBufferImpl in project jaybird by FirebirdSQL.

the class FBConnectionTest method transactionSettingsNotShared.

/**
 * Rationale: see <a href="http://tracker.firebirdsql.org/browse/JDBC-386">JDBC-386</a>
 */
@Test
public void transactionSettingsNotShared() throws Exception {
    try (FBConnection con1 = getConnectionViaDriverManager().unwrap(FBConnection.class);
        FBConnection con2 = getConnectionViaDriverManager().unwrap(FBConnection.class)) {
        TransactionParameterBuffer con2Original = con2.getTransactionParameters(Connection.TRANSACTION_REPEATABLE_READ);
        TransactionParameterBufferImpl newParameters = new TransactionParameterBufferImpl();
        newParameters.addArgument(isc_tpb_consistency);
        newParameters.addArgument(isc_tpb_read);
        newParameters.addArgument(isc_tpb_nowait);
        con1.setTransactionParameters(Connection.TRANSACTION_REPEATABLE_READ, newParameters);
        assertEquals("Setting of con1 update", newParameters, con1.getTransactionParameters(Connection.TRANSACTION_REPEATABLE_READ));
        assertEquals("Setting of con2 unchanged", con2Original, con2.getTransactionParameters(Connection.TRANSACTION_REPEATABLE_READ));
        assertNotEquals("Setting of con2 not equal to new config of con1", newParameters, con2.getTransactionParameters(Connection.TRANSACTION_REPEATABLE_READ));
    }
}
Also used : TransactionParameterBuffer(org.firebirdsql.gds.TransactionParameterBuffer) TransactionParameterBufferImpl(org.firebirdsql.gds.impl.TransactionParameterBufferImpl) Test(org.junit.Test)

Aggregations

TransactionParameterBuffer (org.firebirdsql.gds.TransactionParameterBuffer)10 TransactionParameterBufferImpl (org.firebirdsql.gds.impl.TransactionParameterBufferImpl)10 SQLException (java.sql.SQLException)1 Test (org.junit.Test)1