use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.
the class FBConnection method setTransactionParameters.
@Deprecated
public void setTransactionParameters(int isolationLevel, int[] parameters) throws SQLException {
synchronized (getSynchronizationObject()) {
checkValidity();
TransactionParameterBuffer tpbParams = createTransactionParameterBuffer();
for (int parameter : parameters) {
tpbParams.addArgument(parameter);
}
setTransactionParameters(isolationLevel, tpbParams);
}
}
use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.
the class FBConnectionProperties method getMapper.
public FBTpbMapper getMapper() throws FBResourceException {
if (mapper != null) {
return mapper;
}
if (tpbMapping == null) {
mapper = FBTpbMapper.getDefaultMapper();
} else {
mapper = new FBTpbMapper(tpbMapping, getClass().getClassLoader());
}
mapper.setDefaultTransactionIsolation(defaultTransactionIsolation);
for (Map.Entry<Integer, TransactionParameterBuffer> entry : customMapping.entrySet()) {
Integer isolation = entry.getKey();
TransactionParameterBuffer tpb = entry.getValue();
mapper.setMapping(isolation, tpb);
}
return mapper;
}
use of org.firebirdsql.gds.TransactionParameterBuffer 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 FBResourceException
* if mapping contains keyword that is not
* a TPB parameter.
*/
public static TransactionParameterBuffer processMapping(String mapping) throws FBResourceException {
// 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) {
throw new FBResourceException(parts[1] + " is not valid integer value");
}
token = parts[0];
}
Integer value = ParameterBufferHelper.getTpbParam(token);
if (value == null) {
throw new FBResourceException("Keyword " + token + " unknown. Please check your mapping.");
}
if (argValue == null) {
result.addArgument(value);
} else {
result.addArgument(value, argValue);
}
}
return result;
}
use of org.firebirdsql.gds.TransactionParameterBuffer in project jaybird by FirebirdSQL.
the class TestJnaDatabase 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 TestFBDriver method testTransactionConfigThroughConnectionString.
@Test
public void testTransactionConfigThroughConnectionString() throws Exception {
Properties props = getDefaultPropertiesForConnection();
// Note that for proper testing this needs to be different from the mapping in isc_tpb_mapping.properties
String jdbcUrl = getUrl() + "?TRANSACTION_READ_COMMITTED=isc_tpb_read_committed,isc_tpb_no_rec_version,isc_tpb_write,isc_tpb_nowait";
connection = DriverManager.getConnection(jdbcUrl, 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));
}
Aggregations