GdaConnection

Name

GdaConnection -- Connection management

Synopsis



GdaConnection* gda_connection_new           (CORBA_ORB orb);
GdaConnection* gda_connection_new_from_dsn  (const gchar *dsn_name,
                                             const gchar *username,
                                             const gchar *password);
void        gda_connection_free             (GdaConnection *cnc);
void        gda_connection_set_provider     (GdaConnection *cnc,
                                             gchar *name);
const gchar* gda_connection_get_provider    (GdaConnection *cnc);
gboolean    gda_connection_supports         (GdaConnection *cnc,
                                             GDA_Connection_Feature feature);
void        gda_connection_set_default_db   (GdaConnection *cnc,
                                             gchar *dsn);
gint        gda_connection_open             (GdaConnection *cnc,
                                             const gchar *dsn,
                                             const gchar *user,
                                             const gchar *pwd);
void        gda_connection_close            (GdaConnection *cnc);
GdaRecordset* gda_connection_open_schema    (GdaConnection *cnc,
                                             GDA_Connection_QType t,
                                             ...);
GdaRecordset* gda_connection_open_schema_array
                                            (GdaConnection *cnc,
                                             GDA_Connection_QType t,
                                             GdaConstraint_Element*);
glong       gda_connection_modify_schema    (GdaConnection *cnc,
                                             GDA_Connection_QType t,
                                             ...);
GList*      gda_connection_get_errors       (GdaConnection *cnc);
gint        gda_connection_begin_transaction
                                            (GdaConnection *cnc);
gint        gda_connection_commit_transaction
                                            (GdaConnection *cnc);
gint        gda_connection_rollback_transaction
                                            (GdaConnection *cnc);
GdaRecordset* gda_connection_execute        (GdaConnection *cnc,
                                             gchar *txt,
                                             gulong *reccount,
                                             gulong flags);
gint        gda_connection_start_logging    (GdaConnection *cnc,
                                             gchar *filename);
gint        gda_connection_stop_logging     (GdaConnection *cnc);
gchar*      gda_connection_create_recordset (GdaConnection *cnc,
                                             GdaRecordset *rs);
gint        gda_connection_corba_exception  (GdaConnection *cnc,
                                             CORBA_Environment *ev);
void        gda_connection_add_single_error (GdaConnection *cnc,
                                             GdaError *error);
void        gda_connection_add_error_list   (GdaConnection *cnc,
                                             GList *list);
#define     gda_connection_is_open          (cnc)
#define     gda_connection_get_dsn          (cnc)
#define     gda_connection_get_user         (cnc)
#define     gda_connection_get_password     (cnc)
gchar*      gda_connection_get_version      (GdaConnection *cnc);
gchar*      gda_connection_sql2xml          (GdaConnection *cnc,
                                             const gchar *sql);
gchar*      gda_connection_xml2sql          (GdaConnection *cnc,
                                             const gchar *xml);
void        gda_connection_add_listener     (GdaConnection *cnc,
                                             GdaListener *listener);
void        gda_connection_remove_listener  (GdaConnection *cnc,
                                             GdaListener *listener);

Object Hierarchy


  GtkObject
   +----GdaConnection

Signal Prototypes


"error"     void        user_function      (GdaConnection *gdaconnection,
                                            gpointer arg1,
                                            gpointer user_data);
"warning"   void        user_function      (GdaConnection *gdaconnection,
                                            gpointer arg1,
                                            gpointer user_data);
"open"      void        user_function      (GdaConnection *gdaconnection,
                                            gpointer user_data);
"close"     void        user_function      (GdaConnection *gdaconnection,
                                            gpointer user_data);

Description

Details

gda_connection_new ()

GdaConnection* gda_connection_new           (CORBA_ORB orb);

Allocates space for a client side connection object

orb : the ORB
Returns : the pointer to the allocated object


gda_connection_new_from_dsn ()

GdaConnection* gda_connection_new_from_dsn  (const gchar *dsn_name,
                                             const gchar *username,
                                             const gchar *password);

Creates a GdaConnection object from the configuration stored for the given data source.

dsn_name : Data source name
username : User name
password : Password
Returns : an GdaConnection object already connected to the underlying database.


gda_connection_free ()

void        gda_connection_free             (GdaConnection *cnc);

If the connection is open the connection is closed and all associated objects (commands, recordsets, errors) are deleted. The memory is freed. The connection object cannot be used any more.

cnc : the connection


gda_connection_set_provider ()

void        gda_connection_set_provider     (GdaConnection *cnc,
                                             gchar *name);

Registers name as the provider for this connection. This should be the id of the CORBA server to use

cnc : connection object
name : name of the provider


gda_connection_get_provider ()

const gchar* gda_connection_get_provider    (GdaConnection *cnc);

Retuns the provider used for this connection

cnc : Connection object
Returns : a reference to the provider name


gda_connection_supports ()

gboolean    gda_connection_supports         (GdaConnection *cnc,
                                             GDA_Connection_Feature feature);

Return information on features supported by the underlying database system.

cnc : the connection object
feature : feature to be tested
Returns : whether the requested feature is supported or not


gda_connection_set_default_db ()

void        gda_connection_set_default_db   (GdaConnection *cnc,
                                             gchar *dsn);

Registers the DSN as the name of the default DB to access when the connection is opened

cnc : the connection object
dsn : the DSN of the default database


gda_connection_open ()

gint        gda_connection_open             (GdaConnection *cnc,
                                             const gchar *dsn,
                                             const gchar *user,
                                             const gchar *pwd);

The function activates the correct CORBA server (defined with the #gda_connection_set_provider() function. Then it tries to open the database using the DSN or the default database as a data source. If user or pwd is not NULL, it will overwrite the appropriate entry in the DSN passed as par2. Entries in the DSN have the form <key> = <value> seperated from the database name . Currently the DSN is not parsed.

cnc : the connection object which describes the server and the database name to which the connection shuld be opened
dsn : The DSN of the database. Can be NULL.
user : The username for authentication to the database. Can be NULL.
pwd : The password for authentication to the database. Can be NULL.
Returns : 0 on success, -1 on error


gda_connection_close ()

void        gda_connection_close            (GdaConnection *cnc);

Closes the connection object and all associated GdaRecordset objects. GdaCommand objects are not closed, but can't be used anymore. Transactions pending on this objects are aborted and an error is returned.

cnc : The connection object which should be closed


gda_connection_open_schema ()

GdaRecordset* gda_connection_open_schema    (GdaConnection *cnc,
                                             GDA_Connection_QType t,
                                             ...);

Retrieves meta data about the data source to which the connection object is connected. The constraints is a list of enum/string pairs. The end of the list must be marked by the special value GDA_Connection_no_CONSTRAINT

cnc : Connection object
t : Query type
... : Constraint values
Returns : The recordset which holds the results.


gda_connection_open_schema_array ()

GdaRecordset* gda_connection_open_schema_array
                                            (GdaConnection *cnc,
                                             GDA_Connection_QType t,
                                             GdaConstraint_Element*);

Retrieves meta data about the data source to which the connection object is connected. The elems is an array of Constraint_Element item. The last item must have it's type element set to GDA_Connection_no_CONSTRAINT If elems is NULL, no constraints are used.

cnc : Connection object
t : Query type
Param3 : 
Returns : The recordset which holds the results.


gda_connection_modify_schema ()

glong       gda_connection_modify_schema    (GdaConnection *cnc,
                                             GDA_Connection_QType t,
                                             ...);

cnc : 
t : 
... : 
Returns : 


gda_connection_get_errors ()

GList*      gda_connection_get_errors       (GdaConnection *cnc);

Returns a list of all errors for this connection object. This function also clears the error list. The errors are stored in LIFO order, so the last error which happend is stored as the first element in the list. Advancing the list means to get back in time and retrieve earlier errors.

The farther away from the client the error happens, the later it is in the queue. If an error happens on the client and then in the CORBA layer and then on the server, you will get the server error first.

cnc : the connection object
Returns : a Glist holding the error objects.


gda_connection_begin_transaction ()

gint        gda_connection_begin_transaction
                                            (GdaConnection *cnc);

Start a new transaction on cnc

cnc : the connection object
Returns : 0 if everything is okay, -1 on error


gda_connection_commit_transaction ()

gint        gda_connection_commit_transaction
                                            (GdaConnection *cnc);

Commit a pending transaction on cnc

cnc : the connection object
Returns : 0 if everything is okay, -1 on error


gda_connection_rollback_transaction ()

gint        gda_connection_rollback_transaction
                                            (GdaConnection *cnc);

Abort and rollback a pending transaction on cnc

cnc : the connection object
Returns : 0 if everything is okay, -1 on error


gda_connection_execute ()

GdaRecordset* gda_connection_execute        (GdaConnection *cnc,
                                             gchar *txt,
                                             gulong *reccount,
                                             gulong flags);

Executes txt. An internal GdaCommand object is used for execution. This command object is destroyed automatically after the commadn has finished.

cnc : the connection
txt : the statement to execute
reccount : a pointer to a gulong. The number of affected records is stored in the space where the pointer points to
flags : falgs (currently unused
Returns : a recordset on success or NULL on error.


gda_connection_start_logging ()

gint        gda_connection_start_logging    (GdaConnection *cnc,
                                             gchar *filename);

This function causes the server to log the statements it executes in filename.

cnc : the connection
filename : the name of the logfile
Returns : -1 on error and 0 if everything is okay


gda_connection_stop_logging ()

gint        gda_connection_stop_logging     (GdaConnection *cnc);

This function stops the database server logs

cnc : the connection
Returns : -1 on error and 0 if everything is okay


gda_connection_create_recordset ()

gchar*      gda_connection_create_recordset (GdaConnection *cnc,
                                             GdaRecordset *rs);

cnc : 
rs : 
Returns : 


gda_connection_corba_exception ()

gint        gda_connection_corba_exception  (GdaConnection *cnc,
                                             CORBA_Environment *ev);

cnc : 
ev : 
Returns : 


gda_connection_add_single_error ()

void        gda_connection_add_single_error (GdaConnection *cnc,
                                             GdaError *error);

cnc : a connection
error : error object


gda_connection_add_error_list ()

void        gda_connection_add_error_list   (GdaConnection *cnc,
                                             GList *list);

cnc : 
list : 


gda_connection_is_open()

#define            gda_connection_is_open(cnc)        ((cnc) ? GDA_CONNECTION(cnc)->is_open : FALSE)

cnc : 


gda_connection_get_dsn()

#define            gda_connection_get_dsn(cnc)        ((cnc) ? GDA_CONNECTION(cnc)->database : 0)

cnc : 


gda_connection_get_user()

#define            gda_connection_get_user(cnc)       ((cnc) ? GDA_CONNECTION(cnc)->user : 0)

cnc : 


gda_connection_get_password()

#define            gda_connection_get_password(cnc)   ((cnc) ? GDA_CONNECTION(cnc)->passwd : 0)

cnc : 


gda_connection_get_version ()

gchar*      gda_connection_get_version      (GdaConnection *cnc);

Get the version number of the underlying provider

cnc : connection
Returns : 


gda_connection_sql2xml ()

gchar*      gda_connection_sql2xml          (GdaConnection *cnc,
                                             const gchar *sql);

Converts the given SQL command to a GdaXmlQuery

cnc : connection
sql : SQL string
Returns : 


gda_connection_xml2sql ()

gchar*      gda_connection_xml2sql          (GdaConnection *cnc,
                                             const gchar *xml);

Converts the given GdaXmlQuery to a SQL string for the underlying provider

cnc : connection
xml : 
Returns : 


gda_connection_add_listener ()

void        gda_connection_add_listener     (GdaConnection *cnc,
                                             GdaListener *listener);

cnc : 
listener : 


gda_connection_remove_listener ()

void        gda_connection_remove_listener  (GdaConnection *cnc,
                                             GdaListener *listener);

cnc : 
listener : 

Signals

The "error" signal

void        user_function                  (GdaConnection *gdaconnection,
                                            gpointer arg1,
                                            gpointer user_data);

gdaconnection :the object which received the signal.
arg1 : 
user_data :user data set when the signal handler was connected.


The "warning" signal

void        user_function                  (GdaConnection *gdaconnection,
                                            gpointer arg1,
                                            gpointer user_data);

gdaconnection :the object which received the signal.
arg1 : 
user_data :user data set when the signal handler was connected.


The "open" signal

void        user_function                  (GdaConnection *gdaconnection,
                                            gpointer user_data);

gdaconnection :the object which received the signal.
user_data :user data set when the signal handler was connected.


The "close" signal

void        user_function                  (GdaConnection *gdaconnection,
                                            gpointer user_data);

gdaconnection :the object which received the signal.
user_data :user data set when the signal handler was connected.