Table of Contents [+/-]
Source distributions of Connector/C++ include an
examples directory that contains usage
examples. These examples explain how to use the following classes:
The examples cover:
Driver class to connect to
Creating tables, inserting rows, fetching rows using (simple) statements
Creating tables, inserting rows, fetching rows using prepared statements
Hints for working around prepared statement limitations
Accessing result set metadata
The examples in this document are only code snippets, not complete
programs. The code snippets provide a brief overview on the API.
For complete programs, check the
directory of your Connector/C++ installation Please also read the
README file in that directory. To test the
example code, edit the
examples.h file in the
examples/ directory to add your connection
information, then rebuild the code by issuing a
The examples in the
How to create a connection, insert data into MySQL and handle exceptions.
How to obtain metadata associated with a connection object, for example, a list of tables, databases, MySQL version, connector version.
How to activate and deactivate the Connector/C++ debug protocol.
A closer look at the exceptions thrown by the connector and how to fetch error information.
How to run Prepared Statements including an example how to handle SQL statements that cannot be prepared by the MySQL Server.
How to use a cursor to fetch data and iterate over a result set.
How to obtain metadata associated with a result set, for example, number of columns and column types.
Result sets returned from metadata methods. (This is more a test than an example.)
Simple standalone program not integrated into regular CMake builds.
How to execute SQL statements without using Prepared Statements.
This example shows how to filter the output of the debug trace. Please see the inline comments for further documentation. This script is unsupported.