Encapsulates a connection to a database.
Exceptions thrown by the OpenDBX classes.
Handling large objects if supported by the database.
Provides result sets from the database.
OpenDBX C++ API.
The OpenDBX C++ API is an object-oriented database abstraction layer based on the procedural C API of the OpenDBX library. The C++ API provides objects encapsulating connections, statements, result sets and large objects.
Using the API starts with establishing a connection to the database server by creating an instance of the Conn class with the parameters backend, host and port. Conn::getCapability() tests the implemented capabilites of the underlying database library while Conn::getOption() and Conn::setOption() has be used to test for and change a number of options. The options must be changed before authenticating the connection with the Conn::bind() method to have any effect. It's also possible to rebind a connection using different credentials after Conn::unbind() had been called. Additionally, the Conn class is able to escape potentially dangerous character sequences with Conn::escape() if e.g. user input should be part of a statement as value.
The Conn::create() method creates and initializes a new statement instance from a SQL string. Currently, there are only simple statement objects implemented, which needs to be complete statements which can be sent to the database with Stmt::execute(). This method returns a Result object encapsulating one or more result sets returned by the database depending on the statement sent.
Each result set must be retrieved using Result::getResult(), while Result::getRows() fetches a row from the current result set if the statement was a SELECT like statement. Otherwise, Result::rowsAffected() can be used to get the number of rows that were touched by the statement. If the statement may return rows, the Result::columnName() and Result::columnType() methods are able to provide some informations about the columns indexed from 0 to n. It's also possible to map the column name with the Result::columnPos() method to the column index which is required be the other column methods. To get the actual value and length of the content in the current row at the given position, the Result::fieldValue() and Result::fieldLength() must be called.
In case the unterlying database library requires special handling of large objects (binary or text LOBs), the value of Result::fieldValue() has to be feed into the Result::getLob() method. It returns a Lob object which enables the application to read from and write to a large object using Lob::read() respectively Lob::write(). This is only necessary if the Conn::getCapability() method returns true when asking for ODBX_CAP_LO.
If an error occurs in any of the object methods, the objects will throw an instance of the Exception class with extends the runtime_error exception of the STL. The instance contains an error message, the OpenDBX error code and an error type indicating the severity of the error. This information can be retrieved by the methods Exception::what(), Exception::getCode() and Exception::getType().
Norbert Sendetzky email@example.com
Generated automatically by Doxygen for opendbx from the source code.