Connecting to Firebird database
When connecting to Firebird database, one have to specify
Database name, Server name and Protocol are combined together in the form of connect string.
This is either name of database file (as seen from the server),
or alias defined in aliases.conf file.
It is better (but not required) to use fully qualified filename,
e.g. "d:\databases\db.fdb"
(avoid using partially specified filenames like "d:databases\db.fdb").
The name of machine the Firebird server and database file resides on.
(Database files must always be on the local drive of Firebird server.)
When connecting using tcp/ip protocol, it is usually possible
to specify tcp/ip address instead of name (like 192.168.12.34:D:\DB.FDB),
however this functionality is not built into Firebird, instead, it is provided
by underlying network layer (e.g. WinSock2), and for some implementations/configurations
it can be much slower than using name.
Here is list of supported protocols, and how to specify them in connect string:
| Syntax | Example |
|---|
Local | <db_file> | D:\DB.FDB |
tcp/ip | <server>:<db_file> | myserver:D:\DB.FDB |
<server>/<port_number>:<db_file> | myserver/3050:D:\DB.FDB |
<server>/<service_name>:<db_file> | myserver/gds_db:D:\DB.FDB |
Named pipes | \\<server>\<db_file> | \\myserver\D:\DB.FDB |
Notes
- Local protocol must be used when connecting to embedded Firebird engine.
- Local protocol can't be used when connecting to Classic Firebird engine.
- Possibility to specify
<port_number> is implemented since Firebird 1.
- Possibility to specify
<service_name> works with all Firebird/InterBase versions.
- Named pipes can only be used if the server runs on Windows NT/2000/XP (because Windows 95/98 can't create named pipes.)
- Don't be confused by syntax of Named pipes protocol; although it resembles connecting
to shared resources, the similarity is just pure coincidence.
You should never share folders with database files for public access.
- Firebird 1.5 server can be configured such that some protocols are disabled.
- Firebird 1.5 also allows using alias instead of file name (configured in
aliases.conf file).
The alias can be simple name, but it can also look like fully qualified filename.
- Firebird does not care at all about database file extension, however
some preferred database file extensions are:
-
*.fdb - Firebird
-
*.ib - InterBase
-
*.gdb - used with pre-IB6 versions (not recommended due to problems with Windows' System Restore "feature")
Users are identified by Username, and validated using Password.
Their privileges can also be determined by specifying Role during connection.
Username and password are either specified by application, e.g. in command line
ISQL D:\DB.FDB -U SYSDBA -P masterkey
or in SQL command
CONNECT 'D:\DB.FDB' USER 'SYSDBA' PASSWORD 'masterkey';
or they can be specified using environment variables. E.g. after setting
SET ISC_USER=SYSDBA
SET ISC_PASSWORD=masterkey
it is enough to connect using
CONNECT 'D:\DB.FDB';
(This functionality is built directly into Firebird client library, no support is required in the application.)
Notes
- Only first 8 characters of Password are verified.
- When specifying non existent Role, or Role not granted to the user,
no error is reported and user is connected using default (
NONE) role.
The way how other parameters are specified depends on access method used (ISQL, FB API, IBO, FIB+ etc.),
so here is just concise list:
- Connection character set (e.g.
SET NAMES <char_set>; command in ISQL).
- Number of buffer pages (e.g.
CACHE clause in CONNECT statement).
- Request to keep stable
RDB$DB_KEY values during connection (e.g. using isc_dpb_dbkey_scope parameter in DPB).
- Request to disable garbage collection during connection (e.g.
-garbage_collect switch of gbak).
- Suppress encrypting password on client.
- Name of message file (not sure if this still works in Firebird).
- Setting database properties, like Forced Writes, Read Only, etc.
Copyright © 2004, 2005 Ivan Prenosil