Application Development with MariaDB Connector/C++
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.
g++ (GNU GCC) command demonstrates how to link an application with the MariaDB Connector/C++ shared library using the
$ g++ -o example example.cpp -std=c++11 -lmariadbcpp
If you are not using the
g++ compiler, please consult your compiler's manual.
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
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
MariaDB Connector/C++ implements many different classes.
Most C++ applications developed using MariaDB Connector/C++ will use some of the following classes:
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