FirebirdSQL logo
 Firebird EventsExamples 

Using the Services API

The ODBC/JDBC driver wraps a great many of the Services API functions.The management console built into the Windows DSN interface provides examples of most of them.One thing you cannot do via the console is create databases.Fear not! the driver has it wrapped!

In the Connection chapter is a table of the keywords available to signify the values for attachments via Firebird’s “regular” API.The table below provides the keywords for the KEYWORD=value parameters for connecting to the server and launching a service request.These are additional to the relevant connection parameters.For some cases, the default settings from the DSN, if used, will be correct for Service requests.

Table 1. Keywords for Service Request Attributes
Keyword Description More Information

BACKUPFILE

Backup file

This is a filesystem path and file name.Unlike a database, a backup path can be a network storage address.

LOGFILE

Path and name of the log file for the service

Optional;valid for any service that provides a log file option.The same filesystem rules apply as for backup files.

CREATE_DB

Create database

See the examples below for usage

BACKUP_DB

Backup database

The path and name of the database backup file, for backups and restores.

RESTORE_DB

The network path and name of the database to which a backup is to be restored.This cannot be a network storage address.The file name part can be an alias, provided the alias exists.

 

REPAIR_DB

Repair database

Local path to the database to be repaired or validated.Remote access is invalid.

COMPACT_DB

Compact database

Not currently applicable to Firebird databases.

DROP_DB

Drop database

Not currently applicable to Firebird databases.

Examples of Services Use

The following samples show how to configure the various service requests.

Creating a Database
SQLConfigDataSource( NULL,
                     ODBC_ADD_DSN,
                     "Firebird/InterBase(r) driver",
                     "ODBC\0"
                     "CREATE_DB = D:\\TestService\\test.fdb\0"
                     "DESCRIPTION = My Firebird database\0"
                     "UID         = SYSDBA\0"
                     "PWD         = masterkey\0"
                     "CHARSET     = NONE\0"
                     "PAGESIZE    = 8192\0"
                     "DIALECT     = 3\0" );

More alternative examples for creating databases are at the end of this chapter.

Backing Up a Database
SQLConfigDataSource( NULL,
                     ODBC_ADD_DSN,
                     "Firebird/InterBase(r) driver",
                     "ODBC\0"
                     "BACKUP_DB = D:\\TestService\\test.fdb\0"
                     "BACKUPFILE = D:\\TestService\\test.fbk\0"
                     "UID         = SYSDBA\0"
                     "PWD         = masterkey\0" );
Restoring a Database
SQLConfigDataSource( NULL,
                     ODBC_ADD_DSN,
                     "Firebird/InterBase(r) driver",
                     "ODBC\0"
                     "RESTORE_DB = D:\\TestService\\testNew.fdb\0"
                     "BACKUPFILE = D:\\TestService\\test.fbk\0"
                     "LOGFILE = D:\\TestService\\test.log\0"
                     "UID         = SYSDBA\0"
                     "PWD         = masterkey\0" );
Repairing a Database
SQLConfigDataSource( NULL,
                     ODBC_ADD_DSN,
                     "Firebird/InterBase(r) driver",
                     "ODBC\0"
                     "REPAIR_DB = D:\\TestService\\test.fdb\0"
                     "UID         = SYSDBA\0"
                     "PWD         = masterkey\0" );