qdb_connect()

Connect to a database

Synopsis:

#include <qdb/qdb.h>

qdb_hdl_t   *qdb_connect( const char *dbname,
                          int flags );

Arguments:

dbname
The database device name (for example, /dev/qdb/customerdb).
flags
Flags which can be used to control attributes of the connection. This argument can be 0, or a combination of:
  • QDB_CONN_DFLT_SHARE — Use the default database connection share mode (as given to the -C command-line option to qdb). Without this flag, a private connection is forced.
  • QDB_CONN_NONBLOCKING — If this bit is set, qdb_statement() fails and returns immediately (setting errno to EBUSY) if the database file is locked. By default, qdb_statement() waits for at least the busy timeout period (set using qdb_setbusytimeout()) if the database is locked, before failing and returning.

    Setting this bit also makes subsequent calls to qdb_connect() non-blocking (as if the -T commandline option were 0).

  • QDB_CONN_STMT_ASYNC — Execute statements asynchronously. In this mode, qdb_statement() may return before the statement has completed execution against the database (see "Using asynchronous mode").

Library:

qdb

Description:

This function connects to the database specified by dbname, and returns a pointer to the database connection. You need to call this function for every database, or for concurrent access to one database.

Note: Two threads can share the same database connection, provided they coordinate between themselves. Alternatively, each thread can call qdb_connect() and have its own connection.

You should disconnect all connections with a call to qdb_disconnect() when you're finished using them.

Returns:

A valid pointer to an opaque database connection (qdb_hdl_t)
Success.
NULL
An error occurred (errno is set).

Classification:

QNX Neutrino

Safety:  
Interrupt handler No
Signal handler No
Thread Yes