use of org.firebirdsql.gds.ng.FbService in project jaybird by FirebirdSQL.
the class TestServicesAPI method attachToServiceManager.
private FbService attachToServiceManager() throws SQLException {
FbService service = dbFactory.serviceConnect(createServiceProperties());
service.attach();
assertTrue("Handle should be attached when isc_service_attach returns normally.", service.isAttached());
return service;
}
use of org.firebirdsql.gds.ng.FbService in project jaybird by FirebirdSQL.
the class TestServicesAPI method testServicesManagerAttachAndDetach.
@Test
public void testServicesManagerAttachAndDetach() throws SQLException {
FbService service = dbFactory.serviceConnect(createServiceProperties());
assertFalse("Handle should be unattached when created.", service.isAttached());
service.attach();
assertTrue("Handle should be attached when isc_service_attach returns normally.", service.isAttached());
service.close();
assertFalse("Handle should be detached when isc_service_detach returns normally.", service.isAttached());
}
use of org.firebirdsql.gds.ng.FbService in project jaybird by FirebirdSQL.
the class TestServicesAPI method testBackupAndRestore.
@Test
public void testBackupAndRestore() throws Exception {
try (FbService service = attachToServiceManager()) {
backupDatabase(service);
}
dropDatabase();
try (FbService service = attachToServiceManager()) {
restoreDatabase(service);
}
connectToDatabase();
}
use of org.firebirdsql.gds.ng.FbService in project jaybird by FirebirdSQL.
the class FBMaintenanceManager method shutdownDatabase.
public void shutdownDatabase(byte operationMode, int shutdownModeEx, int timeout) throws SQLException {
if (operationMode != OPERATION_MODE_MULTI && operationMode != OPERATION_MODE_SINGLE && operationMode != OPERATION_MODE_FULL_SHUTDOWN) {
throw new IllegalArgumentException("Operation mode must be one of: OPERATION_MODE_MULTI, " + "OPERATION_MODE_SINGLE, OPERATION_MODE_FULL_SHUTDOWN");
}
if (shutdownModeEx != SHUTDOWNEX_FORCE && shutdownModeEx != SHUTDOWNEX_ATTACHMENTS && shutdownModeEx != SHUTDOWNEX_TRANSACTIONS) {
throw new IllegalArgumentException("Extended shutdown mode must be " + "one of: SHUTDOWNEX_FORCE, SHUTDOWNEX_ATTACHMENTS, SHUTDOWNEX_TRANSACTIONS");
}
if (timeout < 0) {
throw new IllegalArgumentException("Timeout must be >= 0");
}
try (FbService service = attachServiceManager()) {
ServiceRequestBuffer srb = createDefaultPropertiesSRB(service);
srb.addArgument(isc_spb_prp_shutdown_mode, operationMode);
srb.addArgument(shutdownModeEx, timeout);
executeServicesOperation(service, srb);
}
}
use of org.firebirdsql.gds.ng.FbService in project jaybird by FirebirdSQL.
the class FBMaintenanceManager method setSweepThreshold.
// ----------- Sweeping -------------------------
public void setSweepThreshold(int transactions) throws SQLException {
if (transactions < 0) {
throw new IllegalArgumentException("transactions must be >= 0");
}
try (FbService service = attachServiceManager()) {
ServiceRequestBuffer srb = createDefaultPropertiesSRB(service);
srb.addArgument(isc_spb_prp_sweep_interval, transactions);
executeServicesOperation(service, srb);
}
}
Aggregations