The download package contains usage examples in the directory
examples/. The examples explain the basic
usage of 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 meta data
The examples in this document are only code snippets. The code
snippets provide a brief overview on the API. They are not
complete programs. Please check the
directory of your MySQL Connector/C++ installation for complete programs.
Please also read the
README file in the
examples/ directory. Note to test the example
code you will first need to edit the
examples.h file in the
examples/ directory, to add your connection
information. Then simply 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 meta data associated with a connection object, for example, a list of tables, databases, MySQL version, connector version.
How to activate and deactivate the MySQL 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 commands that cannot be prepared by the MySQL Server.
How to fetch data and iterate over the result set (cursor).
How to obtain meta data associated with a result set, for example, number of columns and column types.
Result sets returned from meta data methods - this is more a test than much of an example.
Simple standalone program not integrated into regular CMake builds.
How to run SQL commands 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.