open_from_dsn


Description:

public static Connection open_from_dsn (string dsn, string? auth_string, ConnectionOptions options) throws Error

This function is the way of opening database connections with libgda, using a pre-defined data source (DSN), see define_dsn for more information about how to define a DSN.

If you don't want to define a DSN, it is possible to use open_from_string instead of this method.

The dsn string must have the following format: "[<username>[:<password>]@]<DSN>" (if <username> and/or <password> are provided, and auth_string is null, then these username and passwords will be used). Note that if provided, <username> and <password> must be encoded as per RFC 1738, see rfc1738_encode for more information.

The auth_string can contain the authentication information for the server to accept the connection. It is a string containing semi-colon seperated named value, usually like "USERNAME=...;PASSWORD=..." where the ... are replaced by actual values. Note that each name and value must be encoded as per RFC 1738, see rfc1738_encode for more information.

The actual named parameters required depend on the provider being used, and that list is available as the auth_params member of the ProviderInfo structure for each installed provider (use get_provider_info to get it). Also one can use the "gda-sql-5.0 -L" command to list the possible named parameters.

This method may fail with a GDA_CONNECTION_ERROR domain error (see the ConnectionError error codes) or a ConfigError domain error (see the ConfigError error codes).

Parameters:

dsn

data source name.

auth_string

authentication string, or null

options

options for the connection (see ConnectionOptions).

Returns:

a new Connection if connection opening was successful or null if there was an error.