Connection.openFromDsn

This function is the way of opening database connections with libgda, using a pre-defined data source (DSN), see gda.config.Config.defineDsn for more information about how to define a DSN. If you don't want to define a DSN, it is possible to use gda.connection.Connection.openFromString 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 gda.global.rfc1738Encode 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 gda.global.rfc1738Encode 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 #GdaProviderInfo structure for each installed provider (use gda.config.Config.getProviderInfo 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 #GdaConnectionError error codes) or a GDA_CONFIG_ERROR domain error (see the #GdaConfigError error codes).

class Connection
static
openFromDsn

Parameters

dsn string

data source name.

authString string

authentication string, or null

options gda.types.ConnectionOptions

options for the connection (see #GdaConnectionOptions).

Return Value

Type: gda.connection.Connection

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

Throws