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);
}
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;
}
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);
}
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);
}
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));
}
}
Aggregations