OpenDBX/C API/odbx init

From Linuxnetworks
< OpenDBX‎ | C API
Revision as of 22:13, 14 February 2007 by Nose (Talk | contribs)

Jump to: navigation, search


int odbx_init(
    odbx_t** handle,
    const char* backend,
    const char* host,
    const char* port ) 

Description:

Allocates and initializes an opaque object required for all further operations within the OpenDBX library. It is used to identify the connection and to maintain per connection information. Depending on the backend it can open a connection to the database server but often this is done not until performing authentication through odbx_bind(). The pointer of the newly created object is stored in the parameter "handle" provided by the calling function. You must not free the returned object yourself but have to use odbx_finish() instead to avoid memory leaks.

Parameters:

  • handle: Pointer where the newly allocated connection object should be stored
  • backend: Name of the backend you want to use (mysql, pgsql, sqlite and sqlite3 - depends on the installed libraries)
  • host: Host name or IP address of the database server or path to database file
  • port: Port number the database server is listening to

Return values:

  • ODBX_ERR_SUCCESS on success
  • Less than zero if an error occured

Errors:

  • -ODBX_ERR_BACKEND: Any error returned by the backend
  • -ODBX_ERR_PARAM: "handle" is NULL
  • -ODBX_ERR_NOMEM: Allocating new memory failed
  • -ODBX_ERR_TOOLONG: The length of a string exceeded the buffer size
  • -ODBX_ERR_NOTEXIST: Backend library was not found
  • -ODBX_ERR_NOOP: A function does not exist in the backend

See also:



Back to Overview