Search in sources :

Example 11 with ServiceRequestBuffer

use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.

the class FBNBackupManager method getFixupSRB.

private ServiceRequestBuffer getFixupSRB(FbService service) {
    ServiceRequestBuffer restoreSPB = service.createServiceRequestBuffer();
    restoreSPB.addArgument(isc_action_svc_nfix);
    restoreSPB.addArgument(isc_spb_dbname, getDatabase());
    int options = getOptions();
    if (options != 0) {
        restoreSPB.addArgument(isc_spb_options, options);
    }
    return restoreSPB;
}
Also used : ServiceRequestBuffer(org.firebirdsql.gds.ServiceRequestBuffer)

Example 12 with ServiceRequestBuffer

use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.

the class FBStatisticsManager method getTableStatistics.

public void getTableStatistics(String[] tableNames) throws SQLException {
    // create space-separated list of tables
    StringBuilder commandLine = new StringBuilder();
    for (int i = 0; i < tableNames.length; i++) {
        commandLine.append(tableNames[i]);
        if (i < tableNames.length - 1)
            commandLine.append(' ');
    }
    try (FbService service = attachServiceManager()) {
        ServiceRequestBuffer srb = createStatsSRB(service, isc_spb_sts_table);
        srb.addArgument(SpbItems.isc_spb_command_line, commandLine.toString());
        executeServicesOperation(service, srb);
    }
}
Also used : ServiceRequestBuffer(org.firebirdsql.gds.ServiceRequestBuffer) FbService(org.firebirdsql.gds.ng.FbService)

Example 13 with ServiceRequestBuffer

use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.

the class FBTraceManager method getTraceSPB.

/**
 * Creates and returns the "trace" service request buffer for the Service Manager.
 *
 * @param service Service handle
 * @param action
 *         The isc_action_svc_trace_* action to be used
 * @param traceSessionName
 *         The trace session name
 * @param configuration
 *         The trace configuration. For an example, look into fbtrace.conf in the root directory of your Firebird
 *         installation
 * @return the "trace" service request buffer for the Service Manager.
 * @throws SQLException
 */
private ServiceRequestBuffer getTraceSPB(FbService service, int action, String traceSessionName, String configuration) throws SQLException {
    ServiceRequestBuffer traceSPB = getTraceSPB(service, action);
    traceSPB.addArgument(isc_spb_trc_name, traceSessionName);
    traceSPB.addArgument(isc_spb_trc_cfg, configuration);
    return traceSPB;
}
Also used : ServiceRequestBuffer(org.firebirdsql.gds.ServiceRequestBuffer)

Example 14 with ServiceRequestBuffer

use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.

the class FBUserManager method getUserSRB.

/**
 * Generate the service request buffer for the specified action.
 *
 * @param service
 *         Service handle
 * @param action
 * @param user
 * @return the service request buffer for the specified action.
 */
private ServiceRequestBuffer getUserSRB(FbService service, int action, User user) {
    ServiceRequestBuffer srb = service.createServiceRequestBuffer();
    srb.addArgument(action);
    if (user.getUserName() != null) {
        srb.addArgument(isc_spb_sec_username, user.getUserName());
    }
    if (user.getPassword() != null) {
        srb.addArgument(isc_spb_sec_password, user.getPassword());
    }
    if (user.getFirstName() != null) {
        srb.addArgument(isc_spb_sec_firstname, user.getFirstName());
    }
    if (user.getMiddleName() != null) {
        srb.addArgument(isc_spb_sec_middlename, user.getMiddleName());
    }
    if (user.getLastName() != null) {
        srb.addArgument(isc_spb_sec_lastname, user.getLastName());
    }
    if (user.getUserId() != -1) {
        srb.addArgument(isc_spb_sec_userid, user.getUserId());
    }
    if (user.getGroupId() != -1) {
        srb.addArgument(isc_spb_sec_groupid, user.getGroupId());
    }
    return srb;
}
Also used : ServiceRequestBuffer(org.firebirdsql.gds.ServiceRequestBuffer)

Example 15 with ServiceRequestBuffer

use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.

the class FBUserManager method userAction.

/**
 * Perform the specified action.
 *
 * @param action
 * @param user
 * @throws SQLException
 * @throws IOException
 */
private void userAction(int action, User user) throws SQLException, IOException {
    try (FbService service = attachServiceManager()) {
        ServiceRequestBuffer srb = getUserSRB(service, action, user);
        setSecurityDatabaseArgument(srb);
        executeServicesOperation(service, srb);
    }
}
Also used : ServiceRequestBuffer(org.firebirdsql.gds.ServiceRequestBuffer) FbService(org.firebirdsql.gds.ng.FbService)

Aggregations

ServiceRequestBuffer (org.firebirdsql.gds.ServiceRequestBuffer)40 FbService (org.firebirdsql.gds.ng.FbService)20 SQLException (java.sql.SQLException)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 FBManager (org.firebirdsql.management.FBManager)2 Test (org.junit.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileOutputStream (java.io.FileOutputStream)1 ServiceParameterBuffer (org.firebirdsql.gds.ServiceParameterBuffer)1 AbstractFbWireService (org.firebirdsql.gds.ng.wire.AbstractFbWireService)1 FbWireService (org.firebirdsql.gds.ng.wire.FbWireService)1 WireServiceConnection (org.firebirdsql.gds.ng.wire.WireServiceConnection)1