Connecting to a database

Connecting to a database requires that you know the name of the database you want to connect to, and you need a database handle that the qdb client library links against.

 qdb_hdl_t *dbhandle;  // The QDB database handle 
 dbhandle = qdb_connect("/dev/qdb/customerdb", 0);
 if (dbhandle == NULL) {
    fprintf(stderr, "Connect failed: %s\n", strerror(errno));
 }
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.