Database URIs
A key concept in using the Btrieve Login API or the implicit login functionality via the Create or Open functions is the database URI (Uniform Resource Indicator). It provides a syntax to describe the address of a database resource on a server.
This section describes the syntax and semantics of the URIs used in Btrieve APIs.
Syntax
A URI uses the following syntax:
access_method://user@host/dbname?parameters
 
 
An optional user name. The password for the user is specified in parameters if needed. The “@” character must be used to delimit the user name even if no host is specified.
A server where the database is located. The local machine is assumed if host is not specified. Host can be a machine name, an IP address, or the keyword “localhost.”
Note: host is a required element if the URI is accessing a database on a Linux operating system.
table=table – specifies a specific SQL table name. The table name must exist in DDFs for the database.
dbfile=file – name of a file whose location is relative to the data file location entry in DBNAMES.CFG for the current database. Since a relative location is specified, the use of drive letters, full or UNC paths is not permitted. The database engine resolves the full file name. The Pervasive PSQL client does not manipulate file in any manner. Embedded spaces are permitted and are escaped by the database engine.
file=file – specifies a specific data file name. The Pervasive PSQL client normalizes file and replaces the input name with the resultant fully qualified UNC name in the URI before sending the request to the database engine. Drive letters may be used and, if present, are interpreted as client-side drives. Using a UNC path is also permitted, as are embedded spaces.
pwd=password – clear text password. The Pervasive PSQL client changes clear text passwords into encrypted passwords before transmission.
prompt=[ yes | no ] – tells the Pervasive PSQL client how the application wants to handle the login dialog box pop-up when the database engine returns status 170 (Login failed due to missing or invalid user name) or 171 (Login failed because of invalid password). If prompt=yes is specified, the requester always displays the login dialog even if the Prompt for Client Credentials setting is Off. If prompt=no is specified, the requester assumes that the application wants to receive the status 170/171 directly and does not want the requester to display the dialog. This is useful if you want your applications to handle the prompting for credentials in response to any 170 or 171 status codes. Values other than “yes” or “no” are ignored and the requester displays the login dialog based on the Prompt for Client Credentials setting. This option is ignored on Linux machines that are acting in the role of a client.
Parameter Precedence
The database engine enforces a precedence level on the parameters “file,” “table” and “dbfile” when more than one of them is specified in a URI. That is, after parsing, the database engine leaves the parameter with the highest precedence. If two or more have the same precedence, the last parameter in the URI is returned after parsing.
The order of precedence from highest to lowest is “file,” “table” and “dbfile.”
Precedence Examples
 
Special Characters
As with any URI, certain non-alphanumeric characters have special significance in the URI syntax. If you wish to use one of these characters within one of the elements in the URI, you must use an escape sequence to identify the character as actual text rather than a special character. An escape sequence is simply another special character or character combination that represents the plain text equivalent of a special character.
The table below shows the special characters supported by the transactional interface URI syntax, and their associated escape sequences (represented by the percent sign and the hexadecimal value for the specified character).
Although the space character is reserved in the URI specification, it can be used without quotes and without escape sequencing because it is not used as a delimiter. The other symbols in the table above are used as delimiters and therefore must be escaped.
Examples
This section shows examples of URIs using escape sequences to identify special characters used within the field values.
Remarks
Note that an empty user name or password is different than no user name or password. For example, btrv://@host/ has an empty user name, while btrv://host/ has no user name, and btrv://foo@host/?pwd= has a user name of “foo” with an empty password.
Some URIs allow the use of user:password syntax. However, the password is then transmitted as clear text. To prevent the transmission of the password as clear text, the Pervasive PSQL database URI ignores the password if one is provided using the user:password syntax. Use the pwd= parameter to provide a password, which the Pervasive PSQL client changes into an encrypted password before transmission.
Some URIs allow for server based naming authority with a syntax of user@host:port. The Pervasive PSQL database URI does support specifying a port element.
Examples
A URL (or "Uniform Resource Locator") is simply the address of a file or resource on the Internet. The database URI uses the same notion to address a database on a server. This section gives examples of the syntax and semantics of URIs for Pervasive PSQL databases, particularly using the transactional interface access.
Database “demodata” on the local machine. The local machine is running a Windows operating system. The host element is required for Linux operating systems (see the example above).
IPv6
The URI and UNC syntax does not allow certain special characters, such as colons. Since raw IPv6 addresses use colons, different methods of handling UNC paths and URI connections are available. Pervasive PSQL supports IPv6-literal.net Names and Bracketed IPv6 Addresses.
See IPv6 in Getting Started With Pervasive PSQL.