Application Development with MariaDB Connector/C++
This page is part of MariaDB's Documentation.
The parent of this page is: MariaDB Connector/C++
Topics on this page:
Overview
MariaDB Connector/C++ enables C++ applications to establish client connections to MariaDB database products over TLS.
Build Your Application with Connector/C++
When you build a C++ application, your compiler must link your application with the MariaDB Connector/C++ shared library.
The following g++ (GNU GCC) command demonstrates how to link an application with the MariaDB Connector/C++ shared library using the -lmariadbcpp argument:
$ g++ -o example example.cpp -std=c++11 -lmariadbcpp
If you are not using the g++ compiler, please consult your compiler's manual.
Header Files
MariaDB Connector/C++ includes several header files. In some cases, developers might find it useful to inspect the MariaDB Connector/C++ header files to view the definitions of classes, functions, and methods.
The header files:
Contain the definitions of classes, functions, and methods in the
sqlnamespace.Are installed to the
/usr/include/mariadb/conncpp/directory by default on Linux.
C++ applications developed using MariaDB Connector/C++ must include the conncpp.hpp header file.
When a C++ application includes conncpp.hpp, the application will automatically include other header files that are included by conncpp.hpp:
CallableStatement.hppConnection.hppDatabaseMetaData.hppDriver.hppDriverManager.hppException.hppjdbccompat.hppParameterMetaData.hppPreparedStatement.hppResultSet.hppResultSetMetaData.hppSavepoint.hppSQLString.hppStatement.hppTypes.hppWarning.hpp
Classes
MariaDB Connector/C++ implements many different classes.
Most C++ applications developed using MariaDB Connector/C++ will use some of the following classes:
Class | Description |
|---|---|
| Establish a connection to a MariaDB database product. A |
| Provides detailed information about the database metadata, such as database name, version, schemas, tables, columns, procedures, and support for various features. |
| Implements the non-static |
| Implements the static |
| Execute a query that contains variable text. Prepared statements can be used to sanitize input. Therefore, using prepared statements reduces the risk of SQL injection attacks. A |
| Fetch query results. A |
| Provides detailed information about a result set, such as schema name, table name, column names and types, and column attributes; whether a column is auto increment, and nullable. |
| Execute a query that does not contain variable text. A |
