Connection.from_dsn_name


Description:

[ CCode ( has_construct_function = false ) ]
[ Version ( since = "6.0" ) ]
public Connection.from_dsn_name (string dsn_name, string? auth_string, ConnectionOptions options) throws Error

This function creates a new function, using a pre-defined data source (DSN) name, 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 Connection.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 separated 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 <parameter>auth_params </parameter> member of the ProviderInfo structure for each installed provider (use get_provider_info to get it). Also one can use the "gda-sql-6.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 gda_config_error domain error (see the ConfigError error codes).

The returned connection is not yet opened, you need to call open or open_async.

Parameters:

dsn_name

data source name.

auth_string

authentication string, or null

options

options for the connection (see ConnectionOptions).

Returns:

a new Connection or null if there was an error.




2022 vala-language.org