Connector C++

Skip to end of metadata
Go to start of metadata

Connector C++

MySQL Connector/C++ is a MySQL database connector for C++.

The MySQL Connector/C++ is licensed under the terms of the GPL, like most MySQL Connectors. There are special exceptions to the terms and conditions of the GPL as it is applied to this software, see FLOSS License Exception. If you need a non-GPL license for commercial distribution please contact us.

The MySQL Driver for C++ mimics the JDBC 4.0 API. However, Connector/C++ does not implement all of the JDBC 4.0 API. The Connector/C++ 1,0.5 GA release features the following classes:

  • Connection
  • DatabaseMetaData
  • Driver
  • PreparedStatement
  • ResultSet
  • ResultSetMetaData
  • Savepoint
  • Statement

The MySQL Connector/C++ implements a significant subset of JDBC 4.0. The JDBC API defines some 450 methods for the above mentioned classes. About 375 (= 80%) of them are implemented and available with the alpha release.

In total you will find about 570 being declared in Connector/C++ and approximately 460 of them being implemented, please check the simplified implementation statistics (1.0.3alpha, 1.0.2alpha for details. Please note, we remove method stubs from releases and you will find only fully implemented methods in a release.

The Driver for C++ can be used to connect to MySQL 5.1 or later. Note - its full functionality is not available when connecting to MySQL 5.0. You cannot connect to MySQL 4.1 or earlier.

Download

You can download the MySQL Connector/C++ at http://dev.mysql.com/downloads/connector/cpp/1.0.html

As of 1.0.4beta we offer both binary and source packages. Available binary packages:

  • Windows
    • Without Installer (zip)
    • MSI Installer
  • Other
    • Compressed GNU TAR archive (tar.gz)

Available source packages:

  • All Platforms
    • Compressed GNU TAR archive (tar.gz)

Source repository

The latest development version is also available through Launchpad at https://launchpad.net/mysql-connector-cpp https://launchpad.net/mysql-connector-cpp.

http://bazaar-vcs.org/ Bazaar is used for the MySQL Connector/C++ code repository. You can check out the source using the bzr command line tool (current development branch):bzr branch lp:~mysql/mysql-connector-cpp/trunk

Supported Platforms

The beta release has been successfully compiled and tested on the following platforms:* AIX

    • 5.3 (PPC32, PPC64)o
  • FreeBSD
    • 6.0 (x86, x86_64)!
    • 7.0 (x86, x86_64)o
  • HPUX
    • 11.11 (PA-RISC 32bit, PA-RISC 64bit)*
    • 11.23 (iA64)o
    • 11.31 (PA-RISC 32bit, PA-RISC 64bit)*
    • 11.31 (iA64)o
  • IBM i5/OS
    • i5/OS (POWER, 32-bit, POWER, 64-bit)!
  • Linux
    • FC4 (x86)
    • RHEL 3 (ia64, x86, x86_64)!
    • RHEL 4 (ia64, x86, x86_64)o
    • RHEL 5 (ia64*, x86, x86_64)o
    • SLES 9 (ia64, x86, x86_64)o
    • SLES 10 (ia64, x86_64)o
    • SuSE 11.0, (x86_64)
    • Ubuntu 8.04 (x86)
    • Ubuntu 8.10 (x86_64)
  • Mac
    • MacOSX 10.4 (PPC32*, PPC64*, x86)
    • MacOSX 10.5 (PPC32*, PPC64*, x86, x86_64)
    • MacOSX 10.6 (x86, x86_64)
  • SunOS
    • Solaris 8 (SPARC32, SPARC64, x86)
    • Solaris 9 (SPARC32, SPARC64, x86)
    • Solaris 10 (SPARC32, SPARC64, x86, x86_64)
    • Solaris 11 (x86, x86_64)*
    • OpenSolaris 2008.11 (x86)
  • Windows
    • XP Professional (32bit)
    • 2003 (64bit)
      An asterix after the platform means that the latest version of the MySQL Enterprise Server may no longer or not yet be supported on that platform but we know, however, that one can build Connector/C++ on that platform.

Future versions aim to support as many of the platforms for which commercial support is available for the latest GA version of the MySQL Server as possible. Please check the support policies at http://www.mysql.com/support/supportedplatforms/enterprise.html for details.

For sales related questions, for example on support or commercial licenses, please write to <sales@mysql.com>.

Advantages

Using MySQL Connector/C++ instead of the MySQL C API (MySQL Client Library) offers the following advantages for C++ users:

  • Convenience of pure C++ - no C function calls
  • Support of a well designed API - JDBC 4.0
  • Support of a commonly known and well documented API - JDBC 4.0
  • Support of the object oriented programming paradigma
  • Shorter development times

Status

MySQL Connector/C++ is available as production version. We kindly ask users and developers to try it out and provide us with feedback.

MySQL Workbench is using a pre-alpha code snapshot for its internal development version. The same is true for the MySQL Connector/OpenOffice.org.

Binary Installation

Unpack the archive into an appropriate directory.

If you plan to use a dynamically linked version of MySQL Connector/C+, make sure that your system can find the MySQL client library. Consult your operating system documentation on how do modify and expand the search patch for libraries. In case you cannot modify the library search path it may help to copy your application, the MySQL Connector/C+ library and the MySQL client library into the same directory. Most systems search for libraries in the current directory.

Please read also Connector C++ Binary Builds for notes on binary portability.

CAUTION: binary compatibility on Windows

The Visual Studio builds of Connector/C++ must not be used with any other CRT (C Run-Time Library, provided by Windows/Visual Studio) but the ones listed at Connector C++ Binary Builds . Using any other CRT with your C++ client application than what we used to build the Connector/C++ binary may cause issues. The Microsoft Visual Studio documentation points out the [potential errors passing CRT objects across DLL boundaries http://msdn.microsoft.com/en-us/library/ms235460.aspx]. Furthermore, your C++ client application must use the same compiler settings for /MD (dynamic linking of CRT), /MDd (dynamic linking of CRT with debug), /MT (static linking of CRT) and /MTd (static linking of CRT with debug). The settings used for building Connector/C++ binaries are documented at the wiki page Connector C++ Binary Builds.

The major version of the compiler used to build the Connector/C++ driver library must match the version of the compiler used to build your C++ client application that is using Connector/C+. For example, you must not use Visual Studio 2008 to link your C+ client application against a Connector/C++ driver library that was build with Visual Studio 2005.

For those combinations of compiler version, target CRT version and your target compiler settings (/MD, /MDd, /MT, /MTd) for which we do not provide a binary download, you have to build Connector/C++ from source.

Windows MSI Installer

Windows users can choose between two binary packages: without installer (unzip in C:) and Windows MSI Installer (x86).

Using the MSI Installer may be more comfortable. Running the MSI Installer does not require any administrative permissions because all it does is to copy files.



The "Typical" installation consists of all required header files and the Release libraries. The only available "Custom" installation option allows you to install additional Debug versions of the driver libraries.

Source Installation

The MySQL Connector/C++ is based on the MySQL client libary (MySQL C API). Connector C/C++ is linked against the MySQL client library. You need to have the MySQL client library installed in order to compile the Connector/C++.

You also need to have the cross-platform build tool CMake 2.6.2 or newer. Check the README file for platform specific notes on Windows and SunOS.

Typically the MySQL client library gets installed by installing the MySQL Server. However, check your operating system documentation for other installation options. Please note also, that MySQL provides downloads for certain platforms which contain no more than the required client library. It is a common mistake, in particular on Windows, to mix header files and binaries from different MySQL client libraries. Of course, this will cause issues.

Building on Unix, Solaris and Mac

1. Run CMake to build a Makefile

me@host:/path/to/mysql-connector-cpp> cmake .
– Check for working C compiler: /usr/local/bin/gcc
– Check for working C compiler: /usr/local/bin/gcc – works
[]
– Generating done
– Build files have been written to: /path/to/mysql-connector-cpp/
Read on at point 3.) in case of configure problems.
2. Use make to build the libraries

me@host:/path/to/mysql-connector-cpp> make clean
me@host:/path/to/mysql-connector-cpp> make
[ 1%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_connection.o
[ 3%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_constructed_resultset.o
[]
[100%] Building CXX object examples/CMakeFiles/statement.dir/statement.o
Linking CXX executable statement

If all goes well, you will find the Connector/C++ library in /path/to/cppconn/libmysqlcppconn.so . In case of problems read on below before you ask for assistance.

3. CMake options: MySQL installation path, debug version and more

In case of configure and/or compile problems check the list of CMake options:

me@host:/path/to/mysql-connector-cpp> cmake -L
[]
CMAKE_BACKWARDS_COMPATIBILITY:STRING=2.4
CMAKE_BUILD_TYPE:STRING=
CMAKE_INSTALL_PREFIX:PATH=/usr/local
EXECUTABLE_OUTPUT_PATH:PATH=
LIBRARY_OUTPUT_PATH:PATH=
MYSQLCPPCONN_GCOV_ENABLE:BOOL=0
MYSQLCPPCONN_TRACE_ENABLE:BOOL=0
MYSQL_CONFIG_EXECUTABLE:FILEPATH=/usr/bin/mysql_config

For example, if your MySQL Server installation path is not /usr/local/mysql and you want to build a debug version of the MySQL Connector/C++ use:

me@host:/path/to/mysql-connector-cpp> cmake -D CMAKE_BUILD_TYPE:STRING=Debug -D MYSQL_CONFIG_EXECUTABLE=/path/to/my/mysql/server/bin/mysql_config .

Verify your settings with cmake -L:

me@host:/path/to/mysql-connector-cpp> cmake -L
[]
CMAKE_BACKWARDS_COMPATIBILITY:STRING=2.4
CMAKE_BUILD_TYPE:STRING=
CMAKE_INSTALL_PREFIX:PATH=/usr/local
EXECUTABLE_OUTPUT_PATH:PATH=
LIBRARY_OUTPUT_PATH:PATH=
MYSQLCPPCONN_GCOV_ENABLE:BOOL=0
MYSQLCPPCONN_TRACE_ENABLE:BOOL=0
MYSQL_CONFIG_EXECUTABLE=/path/to/my/mysql/server/bin/mysql_config

Procees with make clean; make as described at point 2.)

Building on Windows

The basic steps for building the driver on Windows are the same as on Unix: use CMake 2.6.2 or newer to generate build files for your compiler and compile the driver using your compiler.

We are sorry but we cannot formally support other compilers than Microsoft Visual Studio 2003 and above.

Thanks to CMake it is easy for you to try out other compilers. However, you may experience compile warnings, compile errors or linking issues not detected by Visual Studio. We appreciate your patches to fix any of them.

Consult the CMake manual or check cmake --help to find out which build systems are supported by your CMake version.

C:\>cmake --help
cmake version 2.6-patch 2
Usage
[]
Generators

The following generators are available on this platform:
Borland Makefiles = Generates Borland makefiles.
MSYS Makefiles = Generates MSYS makefiles.
MinGW Makefiles = Generates a make file for use with
mingw32-make.
NMake Makefiles = Generates NMake makefiles.
Unix Makefiles = Generates standard UNIX makefiles.
Visual Studio 6 = Generates Visual Studio 6 project files.
Visual Studio 7 = Generates Visual Studio .NET 2002 project
files.
Visual Studio 7 .NET 2003 = Generates Visual Studio .NET 2003 project
files.
Visual Studio 8 2005 = Generates Visual Studio .NET 2005 project
files.
Visual Studio 8 2005 Win64 = Generates Visual Studio .NET 2005 Win64
project files.
Visual Studio 9 2008 = Generates Visual Studio 9 2008 project fil
Visual Studio 9 2008 Win64 = Generates Visual Studio 9 2008 Win64 proje
files.
[]

It is likely that your cmake binary will support more compilers ("generators") than supported by MySQL Connector/C++. We have built the driver using the following generators:

  • Microsoft Visual Studio 8 (Visual Studio 2005)
  • Microsoft Visual Studio 9 (Visual Studio 2008, Visual Studio 2008 Express)
  • NMake

Please see the above Installation instructions for Unix, Solaris and Mac for troubleshooting and configuration hints.

Experimental support for additional generators is discussed outside this wiki:

1. Run CMake to generate build files for your "generator"

1.1 Visual Studio

C:\path_to_mysql_cpp>cmake -G "Visual Studio 9 2008"
– Check for working C compiler: cl
– Check for working C compiler: cl – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working CXX compiler: cl
– Check for working CXX compiler: cl – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– ENV

Unknown macro: {MYSQL_DIR}

=
– MySQL Include dir: C:/Programme/MySQL/MySQL Server 5.1/include
– MySQL Library  : C:/Progams/MySQL/MySQL Server 5.1/lib/opt/mysqlclient.lib
– MySQL Library dir: C:/Progams/MySQL/MySQL Server 5.1/lib/opt
– MySQL CFLAGS:
– MySQL Link flags:
– MySQL Include dir: C:/Progams/MySQL/MySQL Server 5.1/include
– MySQL Library dir: C:/Progams/MySQL/MySQL Server 5.1/lib/opt
– MySQL CFLAGS:
– MySQL Link flags:
– Configuring cppconn
– Configuring test cases
– Looking for isinf
– Looking for isinf - not found
– Looking for isinf
– Looking for isinf - not found.
– Looking for finite
– Looking for finite - not found.
– Configuring C/J junit tests port
– Configuring examples
– Configuring done
– Generating done
– Build files have been written to: C:\path_to_mysql_cpp
C:\path_to_mysql_cpp>dir *.sln *.vcproj
[]
19.11.2008 12:16 23.332 MYSQLCPPCONN.sln
[]
19.11.2008 12:16 27.564 ALL_BUILD.vcproj
19.11.2008 12:16 27.869 INSTALL.vcproj
19.11.2008 12:16 28.073 PACKAGE.vcproj
19.11.2008 12:16 27.495 ZERO_CHECK.vcproj

1.2 NMake

C:\path_to_mysql_cpp>cmake -G "NMake Makefiles"
– The C compiler identification is MSVC
– The CXX compiler identification is MSVC
[]
– Build files have been written to: C:\path_to_mysql_cpp

2. Use your compiler to build the MySQL Conenctor/C++

2.1 Visual Studio - GUI

Open the newly generated project files in the Visual Studio GUI or use a Visual Studio command line to build the driver. The project files contain a variety of different configurations. Among them debug and non-debug versions.

2.2 Visual Studio - NMake

C:\path_to_mysql_cpp>nmake

Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

Scanning dependencies of target mysqlcppconn
[ 2%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_connection.obj
mysql_connection.cpp
[]
Linking CXX executable statement.exe
[100%] Built target statement

Platform Notes on Building

All distributions contain a README file. At the end of the README file contained in a binary distribution you will find the settings used to build the binaries.

If you experience build issues on a platform, it may help to check the settings we use on the platform to build the binary by downloading the binary package.

We have summarized further details at the wiki page Connector C++ Binary Builds.

Getting Started: Usage Examples

The download package contains usage examples in the directory examples/. The examples explain the basic usage of the following classes:

  • Connection
  • DatabaseMetaData
  • Driver
  • PreparedStatement
  • ResultSet
  • ResultSetMetaData
  • Statement

The examples cover:

  • Using the Driver class to connect to MySQL
  • 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
  • Accessing database meta data

The examples on this wiki page are only code snippets. The code snippets provide a brief overview on the API. They are not complete programs. Please check the examples/ directory for complete programs.

The examples will be compiled as part of a normal build (e.g. during make).

Connecting to MySQL

A connection to MySQL is established by retrieving an instance of sql::Connection from a sql::mysql::MySQL_Driver object. A sql::mysql::MySQL_Driver object is returned by sql::mysql::MySQL_Driver::get_mysql_driver_instance().

sql::mysql::MySQL_Driver *driver;
sql::Connection *con;

driver = sql::mysql::MySQL_Driver::Instance();
con = driver->connect("tcp://127.0.0.1:3306", "user", "password");

delete con;

Make sure that you free the sql::Connection object as soon as you do not need it any more. But do not explicitly free the driver object!

(See also: examples/connect.cpp)

Running a simple query

For running simple queries you can use the methods sql::Statement::execute(), sql::Statement::executeQuery() and sql::Statement::executeUpdate(). sql::Statement::execute() should be used if your query does not return a result set or if your query returns more than one result set. See the examples/ directory for more on this.

sql::mysql::MySQL_Driver *driver;
sql::Connection *con;
sql::Statement *stmt

driver = sql::mysql::get_mysql_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "user", "password");

stmt = con->createStatement();
stmt->execute("USE " EXAMPLE_DB);
stmt->execute("DROP TABLE IF EXISTS test");
stmt->execute("CREATE TABLE test(id INT, label CHAR(1))");
stmt->execute("INSERT INTO test(id, label) VALUES (1, 'a')");

delete stmt;
delete con;

Note that you have to free sql::Statement and sql::Connection objects explicitly using delete.

(See also: example/statement.cpp)

Fetching results

The API for fetching result sets is identical for (simple) statments and prepared statements. If your query returns one result set you should use sql::Statement::executeQuery() or sql::PreparedStatement::executeQuery() to run your query. Both methods return sql::ResultSet objects. The preview version does buffer all result sets on the client to support cursors.

// ...
sql::Connection *con;
sql::Statement *stmt
sql::ResultSet *res;
// ...
stmt = con->createStatement();
// ...

res = stmt->executeQuery("SELECT id, label FROM test ORDER BY id ASC");
while (res->next()) {
// You can use either numeric offsets...
cout << "id = " << res->getInt(0);
// ... or column names for accessing results. The latter is recommended.
cout << ", label = '" << res->getString("label") << "'" << endl;
}

delete res;
delete stmt;
delete con;

Note that you have to free sql::Statement, sql::Connection and sql::ResultSet objects explicitly using delete.

The usage of cursors is demonstrated in the examples contained in the download package (examples/statement.cpp, examples/resultset.cpp).

Using Prepared Statements

If you are not familiar with Prepared Statements on MySQL have an extra look at the source code comments and explanations in the file examples/prepared_statement.cpp!

sql::PreparedStatement is created by passing a SQL query to sql::Connection::prepareStatement(). As sql::PreparedStatement is derived from sql::Statement, you will feel familiar with the API once you have learned how to use (simple) statements (sql::Statement). For example, the syntax for fetching results is identical.

// ...
sql::Connection *con;
sql::PreparedStatement *prep_stmt
// ...

prep_stmt = con->prepareStatement("INSERT INTO test(id, label) VALUES (?, ?)");

prep_stmt->setInt(1, 1);
prep_stmt->setString(2, "a");
prep_stmt->execute();

prep_stmt->setInt(1, 2);
prep_stmt->setString(2, "b");
prep_stmt->execute();

delete prep_stmt;
delete con;

As usual, you have to free sql::PreparedStatement and sql::Connection objects explicitly.

References

See the JDBC overview for information on JDBC 4.0. You might also want to have a look at the examples/ directory of the download package.

Tentative 1.1.1 GA TODO

Please note: this is a tentative TODO. We do not promise everything listed below for a certain release. We try to make it, but we do not promise. We may, at any time, re-schedule tasks for other versions.

Coding

  • [done] Prepare support for Visual Studio 2010
  • [done] Prepare support for Connector/C (in addition to the MySQL Client Library)
  • [ongoing] Bugfixes

QA

  • (from Beta) [0/5 = 0%] Develop a set of micro benchmarks for performance regression testing
    • Low priority: may or may not make it into the release!
    • Connection performance
    • SELECT/INSERT using Statement
    • SELECT/INSERT using Prepared Statement
    • Fetching connection metadata
    • Fetching metadata associated with Statements
    • Fetching metadata associated with Prepared Statements
    • Write C/libmysql/Connector-C versions to compare performance for all of the above
    • Develop Win/Linux compatible test script that invokes the micro benchmarks and prints a comprehensive report
  • Clone test set up to cover both Connector/C and libmysql

Other

  • Build binaries using Connector/C instead of the MySQL Client Library

Documentation/Blogging/Publicity etc.

  • Improve documentation
    • Add API reference section
    • Develop additional API examples
  • (from 1.1.0) [low priority ] Blog posting: A threaded Connector/C++ client application

Known Bugs

See bugs.mysql.com.

Change History

MySQL Connector/C++ 1.1.1 GA (not yet released)

  • Added new method ResultSetMetaData::isNumeric() and implemented it in all classes that subclass from it. (Andrey)
  • Added MySQL_Connection::getLastStatementInfo() which returns back the value of the mysql_info() function of libmysql / Connector/C. (Andrey)

MySQL Connector/C++ 1.1.0 GA (13.09.2010)

  • Added Driver::threadInit() and Driver::threadEnd() methods. Every thread of a threaded client must call Driver::threadInit() at the very start of the thread before it does anything else with Connector/C++ and every thread must call Driver::threadEnd() when it finishes. You can find an example demonstrating the use in examples/pthreads.cpp. It is strongly discouraged to share connections between threads. It is theoretically possible, if you set certain (undocumented) mutexes, but it is not supported at all. Use one connection per thread. Do not have two threads using the same connection at the same time. Please check the C API notes on threading on the MySQL manual. Connector/C++ wraps the C API. (Lawrin, Andrey, Ulf)
  • Changed FindMySQL.cm so it looks for mysqlclient in the ENV
    Unknown macro: {MySQL_DIR}

    \lib, as that is where it's located in (some) Connector/C distros, (Lawrin)

  • Fixed bug in CmakeLists,txt - it didn't really use ENV
    Unknown macro: {BOOST_ROOT}

    , boost wasn't searched in the directory set in that environment variable. (Lawrin)

  • Fixed http://bugs.mysql.com/bug.php?id=51562 : error messages did not get reported properly if error occured after query execution and before fetching data within the underlying C API call mysql_use|store_result. (Andrey)
  • BIT fields are now correctly decoded. (Andrey)
  • Connection::getClientOption(const sql::SQLString & optionName, void * optionValue) now accepts the optionName values "metadataUseInfoSchema", "defaultStatementResultType", "defaultPreparedStatementResultType", "characterSetResults". In the previous version only "metadataUseInfoSchema" was allowed. The same is true for Connection::setClientOption().
  • Fixed http://bugs.mysql.com/bug.php?id=45048 "prepared statements corrupt the heap". ResultBind is back in the prepared statement, but shared with the result set. (Andrey)
  • get_driver_instance() is only available in dynamic library builds, static builds won't have this symbol. This is done, because someone might decided to load the dll with LoadLibrary/dlopen and needs an entry point to start using the library (some kind of a Driver Manager). For those, who don't use cmake for building you need to define mysqlcppconn_EXPORTS if you are loading dynamically and want to use that entry point. (Andrey)
  • ABI change - added support for optional run-time dynamic loading of the MySQL Client Library. This is useful if you want to re-distribute a certain client library with the connector and make sure that it gets used. It also allows you to use a different client library for every connection. As it is an advanced feature it is not enabled by default. By default the MySQL Client Library will be linked at compile time just as in every version before.
  • Fixed bug in ResultSetMetaData for normal statements and prepared ones, getScale() and getPrecision() did return wrong results. (Andrey)
  • Fixed http://bugs.mysql.com/bug.php?id=45846 . Excluding dynamically generated and platform specific header files source packages generated using pack (Ulf).
  • Connection map property OPT_RECONNECT is now of type boolean (was long long).
  • We now check LDFLAGS, CXXFLAGS and CPPFLAGS from the environment for every binary we generate. (Ulf, Kent)
  • Fixed http://bugs.mysql.com/bug.php?id=45843: cmake error if configuring an out of source build (when not calling cmake in the root directory). (Ulf)
  • Fixed http://bugs.mysql.com/bug.php?id=44931: missing includes when using GCC 4.4. Note that GCC 4.4 is not yet in use for any official MySQL builds. (Ulf, Lawrin)
  • Fixed a performance issue of Prepared Statements. Reading large result sets has been slow - think O(n^2). Patch by Frank Schoenheit from the OpenOffice.org Base team. (Ulf)
  • Exchanged most use cases of std::auto_ptr with boost::scoped_ptr. Migrated from own solution to boost::scoped_array. In addition, migrated from another own solution to boost::shared_ptr/weak_ptr for guarding access around result sets. (Andrey)
  • API incompatible change: ConnectPropertyVal is no more a struct by a typedef that uses boost::variant. This will break your build but is pretty easy to fix. If you had code like —
    Unknown macro: { sql}


    Your new code you will like this:

    connection_properties["password"] = sql::ConnectPropertyVal(passwd);

    Which is simpler. (Andrey)

  • Fixed a bug in PS, which in combination of preparing a stored procedures without any parameters was leading to exception, which was a problem, and was leading to another problem which manifested itself with double free. All similar code snippets in the Connector were fixed. (Andrey)
  • The driver makes use of some Boost components (http://www.boost.org). You need to have Boost 1.34.0 or newer installed on your system in order to compile the driver from source. Binary distributions have no additional dependencies over 1.0.5.

MySQL Connector/C++ 1.0.5 GA (21.04.2009)

  • Changed the interface of sql::ConnectionMetaData, sql::ResultSetMetaData and sql::ParameterMetaData to have a protected destructor. In this way the client code doesn't need, and won't be able, to destruct the metadata objects returned by the connector. The connector will handle their destruction. This enables statements like: connection->getMetaData->getSchema(); without the result of leaking memory because we lost the pointer returned by getMetaData(). (Lawrin, Andrey)
  • Large overhaul of the code to improve the memory management to not leak in exceptional situations. Big improvement compared to Beta1. (Andrey)
  • Fixed the interface of sql::Driver and sql::Connection so they accept the options map by alias instead of by value. (Andrey)
  • Changed the return type of sql::SQLException::getSQLState() from std::string to const char * to be consistent with std::exception::what(). (Andrey)
  • Implemented getResultSetType() and setResultSetType() for Statement. Used are TYPE_FORWARD_ONLY, which means unbuffered result set and TYPE_SCROLL_INSENSITIVE, which means buffered result set. (Andrey)
  • Implemented getResultSetType() for PreparedStatement. The setter is not implemented because currently PreparedStatement can't do refetching and storing the result means the bind buffers will be correct. (Andrey)
  • Added "defaultStatementResultType" to MySQL_Connection::setClientOption() as an option. Also the method now returns `sql::Connection *`. (Andrey)
  • Added Result::getType() and implemented it in the three result set classes.(Andrey)
  • Enabled tracing functionality when building with VC8 and up (VS2005 and up). (Andrey)
  • Added better support for named pipes, on Windows. Use pipe:// and add the path to the pipe. Shared memory connections are currently not supported. (Andrey)
  • Fixed a bug in MySQL_Connection::setSessionVariable() which led to exception being thrown. (Andrey)
  • The driver makes use of some Boost components (http://www.boost.org). You need to have Boost 1.3.4 or newer installed on your system in order to compile the driver from source. Binary installations have no additional dependency over 1.0.5.

MySQL Connector/C++ 1.0.4 Beta (31.03.2009)

  • Prepared support for upcoming Connector/C. (Georg)
  • Added Windows GUI (MSI) installer. (Georg)
  • Bumping up CMake minimum version requirement from 2.4.2 to 2.6.2. We need the latest version for Windows. (Lawrin)
  • Added "metadataUseInfoSchema" to connection propery map which allows you to control the use of the INFORMATION_SCHEMA for meta data. (Andrey)
  • Fixed a bug in all implementations of ResultSet::relative() which was giving wrong return value although positioning was working correctly. (Andrey)
  • Fixed a leak in MySQL_PreparedResultSet when the result was containing a BLOB column. Andrey)
  • Implemented MySQL_ConnectionMetaData::supportsConvert(from, to). (Andrey)
  • Introduced sql::DataType::YEAR to complement MySQL's YEAR type. (Andrey)
  • Introduced PreparedStatement::getMetaData(). (Andrey)
  • Introduced ResultSetMetaData::isZerofill(), which is not in the JDBC specification. (Andrey)
  • Fixed all implementations of ResultSet::isNull() to check whether the current position is on a real row, not isBeforeFirst() nor isAfterLast(), like all getXXX methods do. (Andrey)
  • Implementation for MySQL_DatabaseMetaData::getProcedures() when INFORMATION_SCHEMA is asked not to be used. (Andrey)
  • Removed MySQL_DatabaseMetaData::getProcedureColumns() from the interface. Until now it was returning always an empty result set. Full implementation will be added at a later stage. (Andrey)
  • Changed a bunch of methods of DatabaseMetaData()::getXXX, which returned `int` to return `unsigned int` because it makes more sense. (Andrey)

MySQL Connector/C++ 1.0.3 Alpha (03.03.2009)

  • Added new tests at test/unit/classes. Those tests are mostly about code coverage. Most of the actual functionality of the driver is tested by the tests found at test/CJUnitPort. (Ulf)
  • New data types added to the list returned by DatabaseMetaData::getTypeInfo(): FLOAT UNSIGED, DECIMAL UNSIGNED, DOUBLE UNSIGNED. Those tests may not be in the JDBC specification. However, due to the change you should be able to look up every type and type name returned by, for example, ResultSetMetaData::getColumnTypeName(). (Andrey)
  • MySQL_Driver::getPatchVersion introducted. (Andrey)
  • Major performance improvements due to new buffered resultset implementation by Andrey. (Ulf)
  • Addition of test/unit/README with instructions for writing bug/regression tests. (Ulf)
  • Experimental support for STLPort. This feature may be removed again at any time later without prior warning! Check cmake -L for configuration instructions. (Andrey)
  • Fixed a bug in MySQL_PreparedResultSet::getString(). Returned string had real data but the length was random. Now, the string is initialized with correct length and thus is binary safe. (Andrey)
  • Added properties-enabled (map of key->value) methods for connecting, which add many connect options. (Andrey)
    • Driver::connect( map )
    • Connection::Connection( map )
  • New BLOB implementation. Got rid of sql::Blob in favor of std::istream. C++'s IOStream library is very powerful, similar to PHP's streams. It makes no sense to reinvent the wheel. For example one can pass a std::istringstream object to setBlob() if the data is in memory, or just open a file std::fstream and let it stream to the DB, or write own stream. Similar will be true for getBlob() where we can just copy data, if buffered result set, or stream, if we implement it. (Andrey)
  • Implemented ResultSet::getBlob() which returns std::stream. (Andrey)
  • Fixed MySQL_DatabaseMetaData::getTablePrivileges() to work correctly. Test cases added in the first unit testing framework. (Andrey)
  • Implemented MySQL_Connection::setSessionVariable() for setting variables like sql_mode. (Andrey)
  • Implemented MySQL_DatabaseMetaData::getColumnPrivileges(). (Andrey)
  • cppconn/datatype.h changed and used again. Reimplemented the type subsystem to be more usable - more types for binary and non-binary strings. (Andrey)
  • Implementation for MySQL_DatabaseMetaData::getImportedKeys() for MySQL versions before 5.1.16 using SHOW, and above using INFORMATION_SCHEMA. (Andrey)
  • Implemented MySQL_ConnectionMetaData::getProcedureColumns(). (Andrey)
  • make package_source packs now with bzip2. (Andrey)
  • Re-added getTypeInfo() with information about all types supported by MySQL and the sql::DataType. (Andrey)
  • Exchanged the implementation of MySQL_ConstructedResultSet to use more efficient non O(n) but O(1) access method. This should improve the speed with which the metadata result sets are used. Also, there is less copy during the construction of the result set, which means that all result sets returned from the metadata functions will be faster. (Andrey)
  • Introduced, internally, sql::mysql::MyVal which has implicit constructors used in mysql_metadata.cpp to create result sets with more native data instead of always string (varchar). (Andrey)
  • Renamed ResultSet::getLong() to ResultSet::getInt64(). resultset.h includes typdefs for Windows to be able to use int64_t. (Andrey)
  • Introduced ResultSet::getUInt() and ResultSet::getUInt64(). (Andrey)
  • Corrected handling of unsigned server types. Now returning correct values (Andrey)
  • Fixed handling of numeric columns in ResultSetMetaData::isCaseSensitive to return false. (Andrey)
  • Better implementation for ResultSetMetaData::isReadOnly. Values generated from views are read-only. Seems that these generated values don't have `db` in MYSQL_FIELD set, while all normal columns do have. (Andrey)
  • Implemented MySQL_DatabaseMetaData::getExportedKeys(). (Andrey)
  • Implemented MySQL_DatabaseMetaData::getCrossReference(). (Andrey)

MySQL Connector/C++ 1.0.2 Alpha (19. December 2008)

  • Adding test/unit as a basis for general unit tests based on the new test framework, see test/unit/example for basic usage examples (Ulf)
  • Fixed MySQL_PreparedStatement::setBlob() to really work. In the tests there is a simple example of a class implementing sql::Blob. (Andrey)
  • Addition of a new unit test framework for JDBC compliance and regression testing. We now include our JDBC compliance tests in the releases (Lawrin)
  • Implemented MySQL_ResultSetMetaData::getPrecision() and MySQL_Prepared_ResultSetMetaData::getPrecision(),updating example. (Andrey)
  • Fixing bug in FLOAT handling. (Andrey)
  • Fixing bug in getString(): getString() is binary safe now (Andrey), new example. (Ulf)
  • Fixing bugs in MySQL_PreparedStatements: setBigInt() and setDatetime() have decremented the internal column index before forwarding the request. This resulted in double-decrement and wrong internal column index. Typical error message: setString() ... invalid "parameterIndex" (Ulf)
  • Adding PHP script examples/cpp_trace_analyzer.php to filter the output of the debug trace. Please see the inline comments for documentation. This script is unsupported! We do no promise to maintain it. (Ulf)
  • Fixed bugs in MySQL_DatabaseMetaData :all supportsCatalogXXXXX methods were returning `true` and all supportSchemaXXXX methods false, which is not as it should be. Now it is reversed, to be consistent with the rest. (Andrey)
  • Implemented MySQL_PreparedStatement::clearParameters(). (Andrey)
  • Fixed a bug in MySQL_ConnectionMetaData::getColumns() which was performing a cartesian product of the columns in the table times the columns matching columnNamePattern. example/connection_meta_schemaobj.cpp extended to cover the function. (Andrey)
  • Fixed lame bug in MySQL_ConnectionMetaData::getIndexInfo() which did not work because the schema name wasn't included in the query sent to the server. (Andrey)
  • Implemented MySQL_PreparedStatement::setNull(). (Andrey)
  • Reverted implementation of MySQL_DatabaseMetaData::getTypeInfo(). Now unimplemented. In addition, removed cppconn/datatype.h for now till we havea proper implementation of the types.
  • DATE, DATETIME and TIME are now being handled when calling MySQL_PreparedResultSet::getString(), ::getDouble, ::getInt(), ::getLong(), ::getBoolean()
  • Fixed MySQL_PreparedStatementResultSet::getDouble() to return proper value when the underlying type is MYSQL_TYPE_FLOAT. (Andrey)
  • Changed ResultSetMetaData::getColumnDisplaySize(), ::getPrecision(), ::getScale() to return unsigned int instead of signed int. (Andrey)
  • Implemented getScale(), getPrecision() and getColumnDisplaySize() for MySQL_ResultSetMetaData and MySQL_Prepared_ResultSetMetaData. (Andrey)

MySQL Connector/C++ 1.0.1 Alpha (2. December 2008)

  • New directory layout
  • MySQL Workbench 5.1 using Connector/C++ for its database connectivity.
  • Addition of Connector/J tests converted
  • Changing sql::DbcException to implement the interface of JDBC's SQLException. And renamed it to sql::SQLException.
  • Renamed sql::DbcInvalidArgument to sql::InvalidArgumentException
  • Renamed sql::DbcMethodNotImplemented to sql::MethodNotImplementedException
  • All tests changed to create TAP compliant output
  • Introduction of experimental CPack support, see make help
  • Metadata: switching to column names "TABLE_CAT" (was: TABLE_CATALOG) and "TABLE_SCHEM" (was: TABLE_SCHEMA) for JDBC compliance
  • ConnectionMetaData::getImportedKeys(): PKTABLE_CATALOG -> PKTABLE_CAT, PKTABLE_SCHEMA -> PKTABLE_SCHEM, FKTABLE_CATALOG -> FKTABLE_CAT, FKTABLE_SCHEMA -> FKTABLE_SCHEM
  • ConnectionMetaData::getPrimaryKeys(): COLUMN -> COLUMN_NAME, SEQUENCE -> KEY_SEQ, INDEX_NAME -> PK_NAME
  • ConnectionMetaData::getProcedures: PROCEDURE_SCHEMA -> PROCEDURE_SCHEM
  • ConnectionMetaData::getTables: TABLE_COMMENT -> REMARKS
  • All examples can be given optional connection parameters on the command line, for example examples/connect tcp://host:port user pass database or examples/connect unix:///path/to/mysql.sock user pass database
  • Adding experimental GCov support, cmake -DMYSQLCPPCONN_GCOV_ENABLE:BOOL=1
  • ConnectionMetaData::getCatalogTerm() returns n/a, there is no counterpart to catalog in Connector/C++
  • Addition of ConnectionMetaData::getSchemas() and Connection::setSchema().
  • Driver Manager removed
  • (n)make install works. You can change the default installation path. Read carefully the messages after executing cmake. Installed are the static and the dynamic version of the library, libmysqlcppconn as well as the generic interface cppconn + 2 MySQL specific headers:

mysql_driver.h (if you want to get your connections from the driver instead of instantiating a MySQL_Connection object. This makes your code pretty portable against the common interface)

mysql_connection.h - If you intend to link directly to the MySQL_Connection class and use its specifics not found in sql::Connection

However, you can make your application fully abstract by not using the two headers above but the generic headers.

  • sql::mysql::MySQL_SQLException is gone. There is no distinction between server and client (= Connector) caused errors based on the type of the exception. However, you can still check the error code to figure out the reason.

MySQL Connector/C++ 1.0.0 Preview (5. August 2008)

First public release.

Feature requests

  • Adapt STL (suggest details, if you can)
  • Please consider C++ references for Statements, ResultSets, and exceptions, instead of pointers to heap memory. Considering the possible exceptions, it quickly becomes a hassle to ensure that everything is freed correctly. I think C++ programmers are accustomed to the compiler doing all of that for them.

Comparison with MySQL++

Connector/C++ and MySQL++ follow different approaches:

  • Connector/C++ follows the JDBC 4.0 API
  • MySQL++ uses a non-standard API
  • The MySQL++ API is "C+-ish" and rich of C+ specific goodies
  • Connector/C++ is licensed under the GPL (+ FLOSS License Exception)
  • Connector/C++ is also available under a commercial license upon request
  • MySQL++ uses LGPL
  • Connector/C++ is available as a beta
  • MySQL++ offers GA (General Availability) releases

Contact

For general discussion of the MySQL Connector/C++ please use the C/C++ community forum or join the MySQL Connector/C++ mailing list.

Bugs can be reported at http://bugs.mysql.com.

For Licensing questions, and to purchase MySQL Products and Services, please Contact MySQL.

Who's who?

  • Andrey Hristov (Coding, QA)
  • Lawrenty Novitsky (Coding, Porting, QA)
  • Vladimir Kolesnikov (Coding of the initial version)
  • Ulf Wendel (QA)
  • Georg Richter (Windows GUI installer)
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Oracle community and they might not be employed or in any way formally affiliated with Oracle. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Oracle nor any other party necessarily agrees with them.