Search in sources :

Example 26 with FbService

use of org.firebirdsql.gds.ng.FbService in project jaybird by FirebirdSQL.

the class FBMaintenanceManager method setForcedWrites.

public void setForcedWrites(boolean forced) throws SQLException {
    try (FbService service = attachServiceManager()) {
        ServiceRequestBuffer srb = createDefaultPropertiesSRB(service);
        srb.addArgument(isc_spb_prp_write_mode, (byte) (forced ? isc_spb_prp_wm_sync : isc_spb_prp_wm_async));
        executeServicesOperation(service, srb);
    }
}
Also used : ServiceRequestBuffer(org.firebirdsql.gds.ServiceRequestBuffer) FbService(org.firebirdsql.gds.ng.FbService)

Example 27 with FbService

use of org.firebirdsql.gds.ng.FbService in project jaybird by FirebirdSQL.

the class FBMaintenanceManager method validateDatabase.

public void validateDatabase(int options) throws SQLException {
    if (options < 0 || options != 0 && options != VALIDATE_IGNORE_CHECKSUM && (options & ~VALIDATE_IGNORE_CHECKSUM) != VALIDATE_READ_ONLY && (options & ~VALIDATE_IGNORE_CHECKSUM) != VALIDATE_FULL && (options | (VALIDATE_READ_ONLY | VALIDATE_IGNORE_CHECKSUM)) != options && (options | (VALIDATE_FULL | VALIDATE_IGNORE_CHECKSUM)) != options) {
        throw new IllegalArgumentException("options must be either 0, " + "VALIDATE_READ_ONLY, or VALIDATE_FULL, optionally combined with VALIDATE_IGNORE_CHECKSUM");
    }
    try (FbService service = attachServiceManager()) {
        ServiceRequestBuffer srb = createRepairSRB(service, options | isc_spb_rpr_validate_db);
        executeServicesOperation(service, srb);
    }
}
Also used : ServiceRequestBuffer(org.firebirdsql.gds.ServiceRequestBuffer) FbService(org.firebirdsql.gds.ng.FbService)

Example 28 with FbService

use of org.firebirdsql.gds.ng.FbService in project jaybird by FirebirdSQL.

the class FBMaintenanceManager method executeRepairOperation.

// ----------- Private implementation methods --------------------
/**
 * Execute a isc_spb_rpr_* (repair) services operation.
 *
 * @param operation
 *         The identifier for the operation to be executed
 * @throws SQLException
 *         if a database access error occurs
 */
private void executeRepairOperation(int operation) throws SQLException {
    try (FbService service = attachServiceManager()) {
        ServiceRequestBuffer srb = createRepairSRB(service, operation);
        executeServicesOperation(service, srb);
    }
}
Also used : ServiceRequestBuffer(org.firebirdsql.gds.ServiceRequestBuffer) FbService(org.firebirdsql.gds.ng.FbService)

Example 29 with FbService

use of org.firebirdsql.gds.ng.FbService in project jaybird by FirebirdSQL.

the class TestJnaServiceConnection method identify_unconnected.

@Test
public void identify_unconnected() throws Exception {
    JnaServiceConnection connection = new JnaServiceConnection(factory.getClientLibrary(), connectionInfo);
    FbService db = connection.identify();
    assertFalse("Expected isAttached() to return false", db.isAttached());
    assertThat("Expected zero-valued connection handle", db.getHandle(), equalTo(0));
    assertNull("Expected version string to be null", db.getServerVersion());
    assertNull("Expected version should be null", db.getServerVersion());
}
Also used : FbService(org.firebirdsql.gds.ng.FbService) Test(org.junit.Test)

Aggregations

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