Chapter 22. Connectors and APIs

Table of Contents

22.1. MySQL Connector/ODBC
22.1.1. Connector/ODBC Versions
22.1.2. Connector/ODBC Introduction
22.1.3. Connector/ODBC Installation
22.1.4. Connector/ODBC Configuration
22.1.5. Connector/ODBC Examples
22.1.6. Connector/ODBC Reference
22.1.7. Connector/ODBC Notes and Tips
22.1.8. Connector/ODBC Support
22.2. MySQL Connector/NET
22.2.1. Connector/NET Versions
22.2.2. Connector/NET Installation
22.2.3. Connector/NET Visual Studio Integration
22.2.4. Connector/NET Tutorials
22.2.5. Connector/NET Programming
22.2.6. Connector/NET Connection String Options Reference
22.2.7. Connector/NET API Reference
22.2.8. Connector/NET Support
22.2.9. Connector/NET FAQ
22.3. MySQL Connector/J
22.3.1. Connector/J Versions
22.3.2. Connector/J Installation
22.3.3. Connector/J Examples
22.3.4. Connector/J (JDBC) Reference
22.3.5. Connector/J Notes and Tips
22.3.6. Connector/J Support
22.4. MySQL Connector/MXJ
22.4.1. Connector/MXJ Overview
22.4.2. Connector/MXJ Versions
22.4.3. Connector/MXJ Installation
22.4.4. Connector/MXJ Configuration
22.4.5. Connector/MXJ Reference
22.4.6. Connector/MXJ Notes and Tips
22.4.7. Connector/MXJ Samples
22.4.8. Connector/MXJ Support
22.5. MySQL Connector/C++
22.5.1. MySQL Connector/C++ Binary Installation
22.5.2. MySQL Connector/C++ Source Installation
22.5.3. MySQL Connector/C++ Building Windows applications with Microsoft Visual Studio
22.5.4. MySQL Connector/C++ Building Linux applications with NetBeans
22.5.5. MySQL Connector/C++ Getting Started: Usage Examples
22.5.6. MySQL Connector/C++ Tutorials
22.5.7. MySQL Connector/C++ Debug Tracing
22.5.8. MySQL Connector/C++ Usage Notes
22.5.9. MySQL Connector/C++ Known Bugs and Issues
22.5.10. MySQL Connector/C++ Feature requests
22.5.11. MySQL Connector/C++ Support
22.5.12. MySQL Connector/C++ FAQ
22.6. MySQL Connector/C
22.6.1. Building MySQL Connector/C from the Source Code
22.6.2. Testing MySQL Connector/C
22.6.3. MySQL Connector/C FAQ
22.7. MySQL Connector/
22.7.1. Installation
22.7.2. Getting Started: Connecting to MySQL
22.7.3. Getting Started: Usage Examples
22.7.4. References
22.7.5. Known Bugs
22.7.6. Contact
22.8. libmysqld, the Embedded MySQL Server Library
22.8.1. Compiling Programs with libmysqld
22.8.2. Restrictions When Using the Embedded MySQL Server
22.8.3. Options with the Embedded Server
22.8.4. Embedded Server Examples
22.8.5. Licensing the Embedded Server
22.9. MySQL C API
22.9.1. C API Data Structures
22.9.2. C API Function Overview
22.9.3. C API Function Descriptions
22.9.4. C API Prepared Statements
22.9.5. C API Prepared Statement Data Structures
22.9.6. C API Prepared Statement Function Overview
22.9.7. C API Prepared Statement Function Descriptions
22.9.8. C API Threaded Function Descriptions
22.9.9. C API Embedded Server Function Descriptions
22.9.10. C API Client Plugin Functions
22.9.11. Common Questions and Problems When Using the C API
22.9.12. Controlling Automatic Reconnection Behavior
22.9.13. C API Support for Multiple Statement Execution
22.9.14. C API Prepared Statement Problems
22.9.15. C API Prepared Statement Handling of Date and Time Values
22.9.16. C API Support for Prepared CALL Statements
22.9.17. Building Client Programs
22.10. MySQL PHP API
22.10.1. MySQL
22.10.2. MySQL Improved Extension (Mysqli)
22.10.3. MySQL Native Driver (Mysqlnd)
22.10.4. MySQL Functions (PDO_MYSQL)
22.10.5. Connector/PHP
22.10.6. Common Problems with MySQL and PHP
22.10.7. Enabling Both mysql and mysqli in PHP
22.11. MySQL Perl API
22.12. MySQL Python API
22.13. MySQL Ruby APIs
22.13.1. The MySQL/Ruby API
22.13.2. The Ruby/MySQL API
22.14. MySQL Tcl API
22.15. MySQL Eiffel Wrapper

MySQL Connectors provide connectivity to the MySQL server for client programs. APIs provide low-level access to the MySQL protocol and MySQL resources. Both Connectors and the APIs enable you to connect and execute MySQL statements from another language or environment, including Java (JDBC), ODBC, Perl, Python, PHP, Ruby, and native C and embedded MySQL instances.


Connector version numbers do not correlate with MySQL Server version numbers. See also Table 22.2, “MySQL Connector Versions and MySQL Server Versions”.

A number of connectors are developed by MySQL:

  • Connector/ODBC provides driver support for connecting to a MySQL server using the Open Database Connectivity (ODBC) API. Support is available for ODBC connectivity from Windows, Unix and Mac OS X platforms.

  • Connector/NET enables developers to create .NET applications that use data stored in a MySQL database. Connector/NET implement a fully functional ADO.NET interface and provides support for use with ADO.NET aware tools. Applications that want to use Connector/NET can be written in any of the supported .NET languages.

    The MySQL Visual Studio Plugin works with Connector/NET and Visual Studio 2005. The plugin is a MySQL DDEX Provider, which means that you can use the schema and data manipulation tools within Visual Studio to create and edit objects within a MySQL database.

  • Connector/J provides driver support for connecting to MySQL from a Java application using the standard Java Database Connectivity (JDBC) API.

  • Connector/MXJ is a tool that enables easy deployment and management of MySQL server and database through your Java application.

  • Connector/C++ is a tool that enables easy deployment and management of MySQL server and database through your C++ application.

  • Connector/C is a stand-alone replacement for the MySQL Client Library (libmysql).

  • Connector/ is a tool that enables applications to connect to MySQL server.

There are two direct access methods for using MySQL natively within a C application:

  • The C API provides low-level access to the MySQL protocol through the libmysql client library; this is the primary method used to connect to an instance of the MySQL server, and is used both by MySQL command line clients and many of the APIs also detailed in this section. MySQL Connector/C can now also be used for this purpose.

  • libmysqld is an embedded MySQL server library that enables you to embed an instance of the MySQL server into your C applications.

If you need to access MySQL from a C application, or build an interface to MySQL for a language not supported by the Connectors or APIs in this chapter, the C API is where you would start. A number of programmers utilities are available to help with the process, and also covered in this section.

The remaining APIs provide an interface to MySQL from specific application langauges. These solutions are not developed or supported by MySQL. Basic information on their usage and abilities is provided here for reference purposes only.

All the language APIs are developed using one of two methods, using libmysql or by building a native driver. The two solutions offer different benefits:

  • Using libmysql offers complete compatibility with MySQL as it uses the same libraries as the MySQL client applications. However, the feature set is limited to the implementation and interfaces exposed through libmysql and the performance may be lower as data is copied between the native langiage, and the MySQL API components. MySQL Connector/C is a possible alternative to using libmysql.

  • Native drivers are an implementation of the MySQL network protocol entirely within the host language or environment. Native drivers are fast, as there is less copying of data between components, and they can offer advanced functionality not available through the standard MySQL API. Native drivers are also easier to build and deploy, as you do not need a copy of the MySQL client libraries to build the native driver components.

A list of many of the libraries and interfaces available for MySQL are shown in the table. See Table 22.1, “MySQL APIs and Interfaces”.

Table 22.1. MySQL APIs and Interfaces

AdaMySQL Bindings for GNU AdalibmysqlSee MySQL Bindings for GNU Ada
CConnector/CReplacement for libmysqlSee Section 22.6, “MySQL Connector/C”.
C++Connector/C++libmysqlSee Section 22.5, “MySQL Connector/C++”.
 MySQL++libmysqlSee MySQL++ Web site.
 MySQL wrappedlibmysqlSee MySQL wrapped.
CocoaMySQL-CocoalibmysqlCompatible with the Objective-C Cocoa environment. See
DMySQL for DlibmysqlSee MySQL for D.
EiffelEiffel MySQLlibmysqlSee Section 22.15, “MySQL Eiffel Wrapper”.
Erlangerlang-mysql-driverlibmysqlSee erlang-mysql-driver.
HaskellHaskell MySQL BindingsNative DriverSee Brian O'Sullivan's pure Haskell MySQL bindings.
 hsql-mysqllibmysqlSee MySQL driver for Haskell .
Java/JDBCConnector/JNative DriverSee Section 22.3, “MySQL Connector/J”.
KayaMyDBlibmysqlSee MyDB.
LuaLuaSQLlibmysqlSee LuaSQL.
.NET/MonoConnector/NETNative DriverSee Section 22.2, “MySQL Connector/NET”.
Objective CamlMySQL Bindings for OBjective CamllibmysqlSee MySQL Bindings for Objective Caml.
OctaveDatabase bindings for GNU OctavelibmysqlSee Database bindings for GNU Octave.
ODBCConnector/ODBClibmysqlSee Section 22.1, “MySQL Connector/ODBC”.
OpenOfficeMySQL Connector/OpenOffice.orglibmysqlDirect connectivity, without using JDBC/ODBC. See Section 22.7, “MySQL Connector/”.
PerlDBI/DBD::mysqllibmysqlSee Section 22.11, “MySQL Perl API”.
 Net::MySQLNative DriverSee Net::MySQL at CPAN
PHPmysql, ext/mysql interface (deprecated)libmysqlSee Section 22.10.1, “MySQL”.
 mysqli, ext/mysqli interfacelibmysqlSee Section 22.10.2, “MySQL Improved Extension (Mysqli)”.
 PDO_MYSQLlibmysqlSee Section 22.10.4, “MySQL Functions (PDO_MYSQL)”.
 PDO mysqlndNative DriverSee PHP PDO mysqlnd.
PythonMySQLdblibmysqlSee Section 22.12, “MySQL Python API”.
RubyMySQL/RubylibmysqlUses libmysql. See Section 22.13.1, “The MySQL/Ruby API”.
 Ruby/MySQLNative DriverSee Section 22.13.2, “The Ruby/MySQL API”.
SchemeMyscshlibmysqlSee Myscsh.
SPLsql_mysqllibmysqlSee sql_mysql for SPL.
TclMySQLtcllibmysqlSee Section 22.14, “MySQL Tcl API”.

Table 22.2. MySQL Connector Versions and MySQL Server Versions

ConnectorConnector versionMySQL Server version
Connector/C++1.0.5 GA5.1, 5.4, 5.5, 5.6
Connector/OpenOffice.org1.0 GA5.0, 5.1, 5.4, 5.5, 5.6
Connector/J5.1.84.1, 5.0, 5.1, 5.4, 5.5, 5.6
Connector/NET1.0 (No longer supported)4.0, 5.0
Connector/NET5.25.0, 5.1, 5.4, 5.5, 5.6
Connector/NET6.05.0, 5.1, 5.4, 5.5, 5.6
Connector/NET6.15.0, 5.1, 5.4, 5.5, 5.6
Connector/ODBC3.51 (Unicode not supported)4.1, 5.0, 5.1, 5.4, 5.5, 5.6
Connector/ODBC5.14.1.1+, 5.0, 5.1, 5.4, 5.5, 5.6
Copyright © 2010-2020 Platon Technologies, s.r.o.           Home | Man pages | tLDP | Documents | Utilities | About
Design by styleshout