Search in sources :

Example 1 with FbService

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;
}
Also used : FbService(org.firebirdsql.gds.ng.FbService)

Example 2 with FbService

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());
}
Also used : FbService(org.firebirdsql.gds.ng.FbService)

Example 3 with FbService

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();
}
Also used : FbService(org.firebirdsql.gds.ng.FbService)

Example 4 with FbService

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);
    }
}
Also used : ServiceRequestBuffer(org.firebirdsql.gds.ServiceRequestBuffer) FbService(org.firebirdsql.gds.ng.FbService)

Example 5 with FbService

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);
    }
}
Also used : ServiceRequestBuffer(org.firebirdsql.gds.ServiceRequestBuffer) FbService(org.firebirdsql.gds.ng.FbService)

Aggregations

FbService (org.firebirdsql.gds.ng.FbService)29 ServiceRequestBuffer (org.firebirdsql.gds.ServiceRequestBuffer)20 SQLException (java.sql.SQLException)6 Test (org.junit.Test)1