Connecting to a database

Connecting to a database requires that you know its name and use the name to obtain a handle from the QDB client library that your application links with.

The name is used in the device path provided to the connection function:

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 that they coordinate between themselves. Alternatively, each thread can call qdb_connect() and have its own connection.