GdaClient

Name

GdaClient -- Database client access

Synopsis



enum        GdaClientEvent;
struct      GdaClientPrivate;
GdaClient*  gda_client_new                  (void);
GdaConnection* gda_client_open_connection   (GdaClient *client,
                                             const gchar *dsn,
                                             const gchar *username,
                                             const gchar *password,
                                             GdaConnectionOptions options);
GdaConnection* gda_client_open_connection_from_string
                                            (GdaClient *client,
                                             const gchar *provider_id,
                                             const gchar *cnc_string,
                                             GdaConnectionOptions options);
const GList* gda_client_get_connection_list (GdaClient *client);
GdaConnection* gda_client_find_connection   (GdaClient *client,
                                             const gchar *dsn,
                                             const gchar *username,
                                             const gchar *password);
void        gda_client_close_all_connections
                                            (GdaClient *client);
void        gda_client_notify_event         (GdaClient *client,
                                             GdaConnection *cnc,
                                             GdaClientEvent event,
                                             GdaParameterList *params);
void        gda_client_notify_error_event   (GdaClient *client,
                                             GdaConnection *cnc,
                                             GdaError *error);
void        gda_client_notify_connection_opened_event
                                            (GdaClient *client,
                                             GdaConnection *cnc);
void        gda_client_notify_transaction_started_event
                                            (GdaClient *client,
                                             GdaConnection *cnc,
                                             GdaTransaction *xaction);
void        gda_client_notify_transaction_committed_event
                                            (GdaClient *client,
                                             GdaConnection *cnc,
                                             GdaTransaction *xaction);
void        gda_client_notify_transaction_cancelled_event
                                            (GdaClient *client,
                                             GdaConnection *cnc,
                                             GdaTransaction *xaction);
gboolean    gda_client_begin_transaction    (GdaClient *client,
                                             GdaTransaction *xaction);
gboolean    gda_client_commit_transaction   (GdaClient *client,
                                             GdaTransaction *xaction);
gboolean    gda_client_rollback_transaction (GdaClient *client,
                                             GdaTransaction *xaction);

Description

This class is the main entry point for libgda client applications. It provides the way by which client applications open connections.

Details

enum GdaClientEvent

typedef enum {
	GDA_CLIENT_EVENT_INVALID,

	/* events usually notified by the library itself, and which the providers
	   should notify on very special cases (like a transaction being started
	   or committed via a BEGIN/COMMIT command directly sent to the
	   execute_command method on the provider */
	GDA_CLIENT_EVENT_ERROR,                 /* params: "error" */
	GDA_CLIENT_EVENT_CONNECTION_OPENED,     /* params: */
	GDA_CLIENT_EVENT_CONNECTION_CLOSED,     /* params: */
	GDA_CLIENT_EVENT_TRANSACTION_STARTED,   /* params: "transaction" */
	GDA_CLIENT_EVENT_TRANSACTION_COMMITTED, /* params: "transaction" */
	GDA_CLIENT_EVENT_TRANSACTION_CANCELLED, /* params: "transaction" */
} GdaClientEvent;


struct GdaClientPrivate

struct GdaClientPrivate;


gda_client_new ()

GdaClient*  gda_client_new                  (void);

Create a new GdaClient object, which is the entry point for libgda client applications. This object, once created, can be used for opening new database connections and activating other services available to GDA clients.

Returns :

the newly created object.


gda_client_open_connection ()

GdaConnection* gda_client_open_connection   (GdaClient *client,
                                             const gchar *dsn,
                                             const gchar *username,
                                             const gchar *password,
                                             GdaConnectionOptions options);

Establish a connection to a data source.

This function is the most common way of opening database connections with libgda.

client :

a GdaClient object.

dsn :

data source name.

username :

user name.

password :

password for username.

options :

Options for the connection.

Returns :

the opened connection if successful, NULL if there is an error.


gda_client_open_connection_from_string ()

GdaConnection* gda_client_open_connection_from_string
                                            (GdaClient *client,
                                             const gchar *provider_id,
                                             const gchar *cnc_string,
                                             GdaConnectionOptions options);

Open a connection given a provider ID and a connection string. This allows applications to open connections without having to create a data source in the configuration. The format of cnc_string is similar to postgresql and mysql connection strings.

client :

a GdaClient object.

provider_id :

provider ID to connect to.

cnc_string :

connection string.

options :

Returns :

the opened connection if successful, NULL if there is an error.


gda_client_get_connection_list ()

const GList* gda_client_get_connection_list (GdaClient *client);

Get the list of all open connections in the given GdaClient. The GList returned is an internal pointer, so DON'T TRY TO FREE IT.

client :

a GdaClient object.

Returns :

a GList of GdaConnection objects.


gda_client_find_connection ()

GdaConnection* gda_client_find_connection   (GdaClient *client,
                                             const gchar *dsn,
                                             const gchar *username,
                                             const gchar *password);

Look for an open connection given a data source name (per libgda configuration), a username and a password.

This function iterates over the list of open connections in the given GdaClient and looks for one that matches the given data source name, username and password.

client :

a GdaClient object.

dsn :

data source name.

username :

user name.

password :

password for username.

Returns :

a pointer to the found connection, or NULL if it could not be found.


gda_client_close_all_connections ()

void        gda_client_close_all_connections
                                            (GdaClient *client);

Close all connections opened by the given GdaClient object.

client :

a GdaClient object.


gda_client_notify_event ()

void        gda_client_notify_event         (GdaClient *client,
                                             GdaConnection *cnc,
                                             GdaClientEvent event,
                                             GdaParameterList *params);

Notify an event to the given GdaClient's listeners. The event can be anything (see GdaClientEvent) ranging from a connection opening operation, to changes made to a table in an underlying database.

client :

a GdaClient object.

cnc :

a GdaConnection object where the event has occurred.

event :

event ID.

params :

parameters associated with the event.


gda_client_notify_error_event ()

void        gda_client_notify_error_event   (GdaClient *client,
                                             GdaConnection *cnc,
                                             GdaError *error);

Notify the given GdaClient of the GDA_CLIENT_EVENT_ERROR event.

client :

a GdaClient object.

cnc :

a GdaConnection object.

error :

the error to be notified.


gda_client_notify_connection_opened_event ()

void        gda_client_notify_connection_opened_event
                                            (GdaClient *client,
                                             GdaConnection *cnc);

Notify the given GdaClient of the GDA_CLIENT_EVENT_CONNECTION_OPENED event.

client :

a GdaClient object.

cnc :

a GdaConnection object.


gda_client_notify_transaction_started_event ()

void        gda_client_notify_transaction_started_event
                                            (GdaClient *client,
                                             GdaConnection *cnc,
                                             GdaTransaction *xaction);

Notify the given GdaClient of the GDA_CLIENT_EVENT_TRANSACTION_STARTED event.

client :

a GdaClient object.

cnc :

a GdaConnection object.

xaction :

a GdaTransaction object.


gda_client_notify_transaction_committed_event ()

void        gda_client_notify_transaction_committed_event
                                            (GdaClient *client,
                                             GdaConnection *cnc,
                                             GdaTransaction *xaction);

Notify the given GdaClient of the GDA_CLIENT_EVENT_TRANSACTION_COMMITTED event.

client :

a GdaClient object.

cnc :

a GdaConnection object.

xaction :

a GdaTransaction object.


gda_client_notify_transaction_cancelled_event ()

void        gda_client_notify_transaction_cancelled_event
                                            (GdaClient *client,
                                             GdaConnection *cnc,
                                             GdaTransaction *xaction);

Notify the given GdaClient of the GDA_CLIENT_EVENT_TRANSACTION_CANCELLED event.

client :

a GdaClient object.

cnc :

a GdaConnection object.

xaction :

a GdaTransaction object.


gda_client_begin_transaction ()

gboolean    gda_client_begin_transaction    (GdaClient *client,
                                             GdaTransaction *xaction);

Start a transaction on all connections being managed by the given GdaClient. It is important to note that this operates on all connections opened within a GdaClient, which could not be what you're looking for.

To execute a transaction on a unique connection, use gda_connection_begin_transaction, gda_connection_commit_transaction and gda_connection_rollback_transaction.

client :

a GdaClient object.

xaction :

a GdaTransaction object.

Returns :

TRUE if all transactions could be started successfully, or FALSE if one of them fails.


gda_client_commit_transaction ()

gboolean    gda_client_commit_transaction   (GdaClient *client,
                                             GdaTransaction *xaction);

Commit a running transaction on all connections being managed by the given GdaClient. It is important to note that this operates on all connections opened within a GdaClient, which could not be what you're looking for.

To execute a transaction on a unique connection, use gda_connection_begin_transaction, gda_connection_commit_transaction and gda_connection_rollback_transaction.

client :

a GdaClient object.

xaction :

a GdaTransaction object.

Returns :

TRUE if all transactions could be committed successfully, or FALSE if one of them fails.


gda_client_rollback_transaction ()

gboolean    gda_client_rollback_transaction (GdaClient *client,
                                             GdaTransaction *xaction);

Cancels a running transaction on all connections being managed by the given GdaClient. It is important to note that this operates on all connections opened within a GdaClient, which could not be what you're looking for.

To execute a transaction on a unique connection, use gda_connection_begin_transaction, gda_connection_commit_transaction and gda_connection_rollback_transaction.

client :

a GdaClient object.

xaction :

a GdaTransaction object.

Returns :

TRUE if all transactions could be cancelled successfully, or FALSE if one of them fails.

See Also

GdaConnection.