diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-06-29 10:28:15 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-06-29 10:28:15 +0000 |
| commit | 96429a66214858603fff8b687dc777ab1e366ef7 (patch) | |
| tree | 7af2c448a858143247ac384c8a64771aa4a978aa /src/libs/zbxdb | |
| parent | 65dd1614dba5dc1c81e953480e04e38dfda67f67 (diff) | |
| download | zabbix-96429a66214858603fff8b687dc777ab1e366ef7.tar.gz zabbix-96429a66214858603fff8b687dc777ab1e366ef7.tar.xz zabbix-96429a66214858603fff8b687dc777ab1e366ef7.zip | |
- improved non standard PostgreSQL & MySQL port using (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@4388 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxdb')
| -rw-r--r-- | src/libs/zbxdb/db.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/libs/zbxdb/db.c b/src/libs/zbxdb/db.c index 86df930c..52ef7b7c 100644 --- a/src/libs/zbxdb/db.c +++ b/src/libs/zbxdb/db.c @@ -126,35 +126,44 @@ int zbx_db_connect(char *host, char *user, char *password, char *dbname, char *d return ret; #endif #ifdef HAVE_POSTGRESQL -/* conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName); */ -/* conn = PQsetdb(NULL, NULL, NULL, NULL, CONFIG_DBNAME);*/ - conn = PQsetdbLogin(host, NULL, NULL, NULL, dbname, user, password ); + char *cport = NULL; + + if( port ) cport = zbx_dsprintf(cport, "%i", port); + + conn = PQsetdbLogin(host, cport, NULL, NULL, dbname, user, password ); + + zbx_free(cport); /* check to see that the backend connection was successfully made */ if (PQstatus(conn) != CONNECTION_OK) { - zabbix_log(LOG_LEVEL_ERR, "Connection to database '%s' failed.", dbname); + zabbix_log(LOG_LEVEL_ERR, "Connection to database '%s' failed: %s", dbname, PQerrorMessage(conn)); ret = ZBX_DB_FAIL; } return ret; #endif #ifdef HAVE_ORACLE - char connect[MAX_STRING_LEN]; + char connect = NULL; if (SQLO_SUCCESS != sqlo_init(SQLO_OFF, 1, 100)) { zabbix_log(LOG_LEVEL_ERR, "Failed to init libsqlora8"); exit(FAIL); } - /* login */ - zbx_snprintf(connect, sizeof(connect),"%s/%s@%s", user, password, dbname); + + /* login */ /* TODO: how to use port??? */ + connect = zbx_dsprintf(connect, "%s/%s@%s", user, password, dbname); + if (SQLO_SUCCESS != sqlo_connect(&oracle, connect)) { printf("Cannot login with %s\n", connect); zabbix_log(LOG_LEVEL_ERR, "Cannot login with %s", connect); exit(FAIL); } + + zbx_free(connect); + sqlo_autocommit_on(oracle); return ret; |
