use of org.firebirdsql.gds.ng.FbTransaction in project jaybird by FirebirdSQL.
the class TestFBMaintenanceManager method createLimboTransaction.
private void createLimboTransaction(int count) throws Exception {
try (FBConnection conn = (FBConnection) getConnectionViaDriverManager()) {
final FbDatabase fbDatabase = conn.getFbDatabase();
for (int i = 0; i < count; i++) {
TransactionParameterBuffer tpBuf = conn.createTransactionParameterBuffer();
FbTransaction transaction = fbDatabase.startTransaction(tpBuf);
transaction.prepare(null);
}
}
}
use of org.firebirdsql.gds.ng.FbTransaction in project jaybird by FirebirdSQL.
the class TestV10OutputBlob method testReopen.
/**
* Test reopen is not allowed.
*/
@Test
public void testReopen() throws Exception {
expectedException.expect(SQLNonTransientException.class);
expectedException.expect(allOf(errorCodeEquals(ISCConstants.isc_segstr_no_op), fbMessageStartsWith(ISCConstants.isc_segstr_no_op)));
final byte[] baseContent = generateBaseContent();
final int requiredSize = 256;
final byte[] testBytes = generateBlobContent(baseContent, requiredSize);
try (FbWireDatabase db = createDatabaseConnection()) {
final FbTransaction transaction = getTransaction(db);
try {
final FbBlob blob = db.createBlobForOutput(transaction, null);
blob.open();
int bytesWritten = 0;
while (bytesWritten < testBytes.length) {
// TODO the interface for writing blobs should be simpler
byte[] buffer = new byte[Math.min(blob.getMaximumSegmentSize(), testBytes.length - bytesWritten)];
System.arraycopy(testBytes, bytesWritten, buffer, 0, buffer.length);
blob.putSegment(buffer);
bytesWritten += buffer.length;
}
blob.close();
// Reopen
blob.open();
} finally {
transaction.commit();
}
}
}
use of org.firebirdsql.gds.ng.FbTransaction in project jaybird by FirebirdSQL.
the class TestV10OutputBlob method testIsEof_afterClose.
/**
* Test if blob is eof after close.
*/
@Test
public void testIsEof_afterClose() throws Exception {
try (FbWireDatabase db = createDatabaseConnection()) {
final FbTransaction transaction = getTransaction(db);
try {
FbBlob blob = db.createBlobForOutput(transaction, null);
assumeTrue("Output blob before open should be eof", blob.isEof());
blob.open();
blob.close();
assertTrue("Output blob after close should be eof", blob.isEof());
} finally {
transaction.commit();
}
}
}
use of org.firebirdsql.gds.ng.FbTransaction in project jaybird by FirebirdSQL.
the class TestV10OutputBlob method testDoubleOpen.
/**
* Test double open is not allowed.
*/
@Test
public void testDoubleOpen() throws Exception {
expectedException.expect(SQLNonTransientException.class);
expectedException.expect(allOf(errorCodeEquals(ISCConstants.isc_no_segstr_close), fbMessageStartsWith(ISCConstants.isc_no_segstr_close)));
try (FbWireDatabase db = createDatabaseConnection()) {
final FbTransaction transaction = getTransaction(db);
try {
final FbBlob blob = db.createBlobForOutput(transaction, null);
blob.open();
blob.open();
} finally {
transaction.commit();
}
}
}
Aggregations