Connecting to a database

Connecting to a database requires that you know its name and use the name to specify the database device path when connecting through the QDB client library linked with your application. When you call the connect function, the library returns a handle that you can subsequently use for accessing the database:

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: Multiple threads can share a database connection, provided that they coordinate amongst themselves. Alternatively, each thread can call qdb_connect() and have its own connection.