use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.
the class TestJaybirdBlobBackupProblem method startBackup.
private void startBackup(FbService service) throws SQLException {
final ServiceRequestBuffer serviceRequestBuffer = service.createServiceRequestBuffer();
serviceRequestBuffer.addArgument(ISCConstants.isc_action_svc_backup);
serviceRequestBuffer.addArgument(SpbItems.isc_spb_verbose);
serviceRequestBuffer.addArgument(SpbItems.isc_spb_dbname, mAbsoluteDatabasePath);
serviceRequestBuffer.addArgument(ISCConstants.isc_spb_bkp_file, mAbsoluteBackupPath);
service.startServiceAction(serviceRequestBuffer);
}
use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.
the class TestServicesAPI method startBackup.
private void startBackup(FbService service) throws SQLException {
ServiceRequestBuffer serviceRequestBuffer = service.createServiceRequestBuffer();
serviceRequestBuffer.addArgument(ISCConstants.isc_action_svc_backup);
serviceRequestBuffer.addArgument(SpbItems.isc_spb_verbose);
serviceRequestBuffer.addArgument(SpbItems.isc_spb_dbname, mAbsoluteDatabasePath);
serviceRequestBuffer.addArgument(ISCConstants.isc_spb_bkp_file, mAbsoluteBackupPath);
service.startServiceAction(serviceRequestBuffer);
}
use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.
the class TestServicesAPI method queryService.
private void queryService(FbService service, String outputFilename) throws Exception {
final ServiceRequestBuffer serviceRequestBuffer = service.createServiceRequestBuffer();
serviceRequestBuffer.addArgument(ISCConstants.isc_info_svc_to_eof);
boolean finished = false;
try (FileOutputStream file = new FileOutputStream(outputFilename)) {
while (!finished) {
byte[] buffer = service.getServiceInfo(null, serviceRequestBuffer, 1024);
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer);
// TODO Find out why unused
final byte firstByte = (byte) byteArrayInputStream.read();
int numberOfBytes = (short) ((byteArrayInputStream.read()) + (byteArrayInputStream.read() << 8));
if (numberOfBytes == 0) {
if (byteArrayInputStream.read() != ISCConstants.isc_info_end)
throw new Exception("Expect ISCConstants.isc_info_end here");
finished = true;
} else {
for (; numberOfBytes >= 0; numberOfBytes--) file.write(byteArrayInputStream.read());
}
}
}
}
use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.
the class FBNBackupManager method getBackupSRB.
/**
* Creates and returns the "backup" service request buffer for the Service Manager.
*
* @param service
* Service handle
* @return the "backup" service request buffer for the Service Manager.
*/
private ServiceRequestBuffer getBackupSRB(FbService service) throws SQLException {
ServiceRequestBuffer backupSPB = service.createServiceRequestBuffer();
backupSPB.addArgument(isc_action_svc_nbak);
backupSPB.addArgument(isc_spb_dbname, getDatabase());
if (backupFiles.isEmpty()) {
throw new SQLException("No backup file specified");
}
String backupFile = backupFiles.get(0);
backupSPB.addArgument(isc_spb_nbk_file, backupFile);
// Previously, the default level was 0, retain that default if no backup GUID has been set
int resolvedBackupLevel = backupLevel == -1 && backupGuid == null ? 0 : backupLevel;
backupSPB.addArgument(isc_spb_nbk_level, resolvedBackupLevel);
if (backupGuid != null) {
backupSPB.addArgument(isc_spb_nbk_guid, backupGuid);
}
int options = getOptions();
if (options != 0) {
backupSPB.addArgument(isc_spb_options, options);
}
return backupSPB;
}
use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.
the class FBNBackupManager method getRestoreSRB.
/**
* Creates and returns the "restore" service request buffer for the Service Manager.
*
* @return the "restore" service request buffer for the Service Manager.
*/
private ServiceRequestBuffer getRestoreSRB(FbService service) throws SQLException {
ServiceRequestBuffer restoreSPB = service.createServiceRequestBuffer();
restoreSPB.addArgument(isc_action_svc_nrest);
restoreSPB.addArgument(isc_spb_dbname, getDatabase());
if (backupFiles.isEmpty()) {
throw new SQLException("No backup file specified");
}
for (String backupFile : backupFiles) {
restoreSPB.addArgument(isc_spb_nbk_file, backupFile);
}
int options = getOptions();
if (options != 0) {
restoreSPB.addArgument(isc_spb_options, options);
}
return restoreSPB;
}
Aggregations