[libgda] Corrected the Oracle connection parameters
- From: Vivien Malerba <vivien src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgda] Corrected the Oracle connection parameters
- Date: Sun, 29 Nov 2009 15:48:00 +0000 (UTC)
commit 43becbbb20d1bd91faa30dbf9b4961de95337387
Author: Vivien Malerba <malerba gnome-db org>
Date: Sun Nov 29 15:11:04 2009 +0100
Corrected the Oracle connection parameters
doc/C/libgda-4.0-docs.sgml | 2 +
doc/C/prov-notes.xml | 44 ++++++++++++++++++
providers/oracle/gda-oracle-provider.c | 74 +++++++++++++++++++----------
providers/oracle/oracle_specs_dsn.xml.in | 4 +-
4 files changed, 97 insertions(+), 27 deletions(-)
---
diff --git a/doc/C/libgda-4.0-docs.sgml b/doc/C/libgda-4.0-docs.sgml
index c8c16a9..d631165 100644
--- a/doc/C/libgda-4.0-docs.sgml
+++ b/doc/C/libgda-4.0-docs.sgml
@@ -42,6 +42,7 @@
<!ENTITY data-validation SYSTEM "data_validation.xml">
<!ENTITY data-select SYSTEM "data_select.xml">
<!ENTITY limitations SYSTEM "limitations.xml">
+<!ENTITY provnotes SYSTEM "prov-notes.xml">
<!ENTITY libgda-GdaCommand SYSTEM "xml/gda-command.xml">
<!ENTITY libgda-config SYSTEM "xml/gda-config.xml">
<!ENTITY libgda-GdaConnection SYSTEM "xml/gda-connection.xml">
@@ -452,6 +453,7 @@
&examples;
&migration;
&migration2;
+ &provnotes;
&limitations;
</part>
<part id="part_libgda_api">
diff --git a/doc/C/prov-notes.xml b/doc/C/prov-notes.xml
new file mode 100644
index 0000000..41be401
--- /dev/null
+++ b/doc/C/prov-notes.xml
@@ -0,0 +1,44 @@
+<chapter id="provider-notes">
+ <title>Provider's notes</title>
+
+ <sect1 id="provider_notes_oracle"><title>For Oracle</title>
+ <para>
+ The following arguments are used to connect to an Oracle database:
+ <table frame="all">
+ <tgroup cols="3" colsep="1" rowsep="1" align="justify">
+ <thead>
+ <row>
+ <entry>Argument name</entry>
+ <entry>Description</entry>
+ <entry>Required</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>DB_NAME</entry>
+ <entry>Service name: global database name entered during database creation (it combines a database name with a domain name), can be left empty to connect to the default database.</entry>
+ <entry>No</entry>
+ </row>
+ <row>
+ <entry>HOST</entry>
+ <entry>Database server: host on which the database server is running</entry>
+ <entry>Yes</entry>
+ </row>
+ <row>
+ <entry>PORT</entry>
+ <entry>Port: database server port (leave this field empty for the default 1521 port)</entry>
+ <entry>No</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ Note however all the arguments above can be replaced by a single TNSNAME argument (see
+ the "Oracle Database Net Services Administrator's Guide" for more information about defining
+ connection identifiers).
+ </para>
+ <para>
+ Also refer to the <link linkend="limitations_oracle">Oracle's provider's limitations</link>.
+ </para>
+ </sect1>
+
+</chapter>
diff --git a/providers/oracle/gda-oracle-provider.c b/providers/oracle/gda-oracle-provider.c
index 93d4c0d..903fe1a 100644
--- a/providers/oracle/gda-oracle-provider.c
+++ b/providers/oracle/gda-oracle-provider.c
@@ -446,13 +446,31 @@ gda_oracle_provider_open_connection (GdaServerProvider *provider, GdaConnection
/* Check for connection parameters */
const gchar *tnsname, *username, *password;
+ gchar *easy = NULL;
tnsname = gda_quark_list_find (params, "TNSNAME");
if (!tnsname) {
- gda_connection_add_event_string (cnc,
- _("The connection string must contain the TNSNAME value"));
- return FALSE;
+ const gchar *host, *port, *dbname;
+ host = gda_quark_list_find (params, "HOST");
+ dbname = gda_quark_list_find (params, "DB_NAME");
+ port = gda_quark_list_find (params, "PORT");
+ if (host) {
+ GString *string;
+ string = g_string_new (host);
+ if (port)
+ g_string_append_printf (string, ":%s", port);
+ if (dbname)
+ g_string_append_printf (string, "/%s", dbname);
+ easy = g_string_free (string, FALSE);
+ }
+ else {
+ gda_connection_add_event_string (cnc,
+ _("The connection string must contain the TNSNAME or the HOST values"));
+ return FALSE;
+ }
}
username = gda_quark_list_find (auth, "USERNAME");
+ if (!username)
+ username = g_get_user_name ();
password = gda_quark_list_find (auth, "PASSWORD");
/* open the real connection to the database */
@@ -539,9 +557,11 @@ gda_oracle_provider_open_connection (GdaServerProvider *provider, GdaConnection
/* attach to Oracle server */
result = OCIServerAttach (cdata->hserver,
cdata->herr,
- (text *) tnsname,
- (ub4) strlen (tnsname),
+ (text *) tnsname ? tnsname : easy,
+ (ub4) strlen (tnsname ? tnsname : easy),
OCI_DEFAULT);
+ g_free (easy);
+
if (gda_oracle_check_result (result, cnc, cdata, OCI_HTYPE_ERROR,
_("Could not attach to the Oracle server"))) {
OCIHandleFree ((dvoid *) cdata->hsession, OCI_HTYPE_SESSION);
@@ -570,12 +590,12 @@ gda_oracle_provider_open_connection (GdaServerProvider *provider, GdaConnection
}
/* set the username attribute */
- result = OCIAttrSet ((dvoid *) cdata->hsession,
- (ub4) OCI_HTYPE_SESSION,
- (dvoid *) username,
- (ub4) strlen (username),
- (ub4) OCI_ATTR_USERNAME,
- cdata->herr);
+ result = OCIAttrSet ((dvoid *) cdata->hsession,
+ (ub4) OCI_HTYPE_SESSION,
+ (dvoid *) username,
+ (ub4) strlen (username),
+ (ub4) OCI_ATTR_USERNAME,
+ cdata->herr);
if (gda_oracle_check_result (result, cnc, cdata, OCI_HTYPE_ERROR,
_("Could not set the Oracle username attribute"))) {
OCIHandleFree ((dvoid *) cdata->hsession, OCI_HTYPE_SESSION);
@@ -587,21 +607,23 @@ gda_oracle_provider_open_connection (GdaServerProvider *provider, GdaConnection
}
/* set the password attribute */
- result = OCIAttrSet ((dvoid *) cdata->hsession,
- (ub4) OCI_HTYPE_SESSION,
- (dvoid *) password,
- (ub4) strlen (password),
- (ub4) OCI_ATTR_PASSWORD,
- cdata->herr);
- if (gda_oracle_check_result (result, cnc, cdata, OCI_HTYPE_ERROR,
- _("Could not set the Oracle password attribute"))) {
- OCIHandleFree ((dvoid *) cdata->hsession, OCI_HTYPE_SESSION);
- OCIHandleFree ((dvoid *) cdata->hserver, OCI_HTYPE_SERVER);
- OCIHandleFree ((dvoid *) cdata->herr, OCI_HTYPE_ERROR);
- OCIHandleFree ((dvoid *) cdata->hservice, OCI_HTYPE_SVCCTX);
- gda_oracle_free_cnc_data (cdata);
- return FALSE;
- }
+ if (password) {
+ result = OCIAttrSet ((dvoid *) cdata->hsession,
+ (ub4) OCI_HTYPE_SESSION,
+ (dvoid *) password,
+ (ub4) strlen (password),
+ (ub4) OCI_ATTR_PASSWORD,
+ cdata->herr);
+ if (gda_oracle_check_result (result, cnc, cdata, OCI_HTYPE_ERROR,
+ _("Could not set the Oracle password attribute"))) {
+ OCIHandleFree ((dvoid *) cdata->hsession, OCI_HTYPE_SESSION);
+ OCIHandleFree ((dvoid *) cdata->hserver, OCI_HTYPE_SERVER);
+ OCIHandleFree ((dvoid *) cdata->herr, OCI_HTYPE_ERROR);
+ OCIHandleFree ((dvoid *) cdata->hservice, OCI_HTYPE_SVCCTX);
+ gda_oracle_free_cnc_data (cdata);
+ return FALSE;
+ }
+ }
/* begin the session */
result = OCISessionBegin (cdata->hservice,
diff --git a/providers/oracle/oracle_specs_dsn.xml.in b/providers/oracle/oracle_specs_dsn.xml.in
index c8d7f9d..4059f84 100644
--- a/providers/oracle/oracle_specs_dsn.xml.in
+++ b/providers/oracle/oracle_specs_dsn.xml.in
@@ -1,6 +1,8 @@
<?xml version="1.0"?>
<data-set-spec>
<parameters>
- <parameter id="DB_NAME" _name="Database name" _descr="The name of a database to use" gdatype="gchararray" nullok="FALSE"/>
+ <parameter id="DB_NAME" _name="Service name" _descr="Global database name entered during database creation (it combines a database name with a domain name)" gdatype="gchararray" nullok="FALSE"/>
+ <parameter id="HOST" _name="Database server" _descr="Host on which the database server is running" gdatype="gchararray"/>
+ <parameter id="PORT" _name="Port" _descr="Database server port (leave this field empty for the default 1521 port)" gdatype="gint"/>
</parameters>
</data-set-spec>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]