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. Configuring Connector/ODBC
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 Support for Windows Store
22.2.8. EF 5 Support
22.2.9. Connector/Net API Reference
22.2.10. Connector/Net Support
22.2.11. Connector/Net FAQ
22.3. MySQL Connector/J
22.3.1. Overview of MySQL Connector/J
22.3.2. Connector/J Versions
22.3.3. Connector/J Installation
22.3.4. Connector/J Examples
22.3.5. Connector/J (JDBC) Reference
22.3.6. JDBC Concepts
22.3.7. Connection Pooling with Connector/J
22.3.8. Load Balancing with Connector/J
22.3.9. Failover with Connector/J
22.3.10. Using the Connector/J Interceptor Classes
22.3.11. Using Connector/J with Tomcat
22.3.12. Using Connector/J with JBoss
22.3.13. Using Connector/J with Spring
22.3.14. Using Connector/J with GlassFish
22.3.15. Troubleshooting Connector/J Applications
22.3.16. Connector/J Support
22.4. MySQL Connector/C++
22.4.1. How to Get MySQL Connector/C++
22.4.2. Installing MySQL Connector/C++ from a Binary Distribution
22.4.3. Installing MySQL Connector/C++ from Source
22.4.4. Building MySQL Connector/C++ Windows Applications with Microsoft Visual Studio
22.4.5. Building MySQL Connector/C++ Linux Applications with NetBeans
22.4.6. MySQL Connector/C++ Getting Started: Usage Examples
22.4.7. MySQL Connector/C++ Tutorials
22.4.8. MySQL Connector/C++ Debug Tracing
22.4.9. MySQL Connector/C++ Usage Notes
22.4.10. MySQL Connector/C++ Known Bugs and Issues
22.4.11. MySQL Connector/C++ Support
22.5. MySQL Connector/C
22.5.1. MySQL Connector/C Versions
22.5.2. MySQL Connector/C Supported Platforms
22.5.3. MySQL Connector/C Distribution Contents
22.5.4. Installing MySQL Connector/C
22.5.5. Building MySQL Connector/C Applications
22.6. MySQL Connector/Python
22.6.1. Guidelines for Python Developers
22.6.2. Connector/Python Versions
22.6.3. Connector/Python Installation
22.6.4. Connector/Python Coding Examples
22.6.5. Connector/Python Tutorials
22.6.6. Connector/Python Connection Arguments
22.6.7. Connector/Python API Reference
22.7. libmysqld, the Embedded MySQL Server Library
22.7.1. Compiling Programs with libmysqld
22.7.2. Restrictions When Using the Embedded MySQL Server
22.7.3. Options with the Embedded Server
22.7.4. Embedded Server Examples
22.8. MySQL C API
22.8.1. MySQL C API Implementations
22.8.2. Simultaneous MySQL Server and MySQL Connector/C Installations
22.8.3. Example C API Client Programs
22.8.4. Building and Running C API Client Programs
22.8.5. C API Data Structures
22.8.6. C API Function Overview
22.8.7. C API Function Descriptions
22.8.8. C API Prepared Statements
22.8.9. C API Prepared Statement Data Structures
22.8.10. C API Prepared Statement Function Overview
22.8.11. C API Prepared Statement Function Descriptions
22.8.12. C API Threaded Function Descriptions
22.8.13. C API Embedded Server Function Descriptions
22.8.14. C API Client Plugin Functions
22.8.15. Common Questions and Problems When Using the C API
22.8.16. Controlling Automatic Reconnection Behavior
22.8.17. C API Support for Multiple Statement Execution
22.8.18. C API Prepared Statement Problems
22.8.19. C API Prepared Statement Handling of Date and Time Values
22.8.20. C API Support for Prepared CALL Statements
22.9.1. Overview of the MySQL PHP drivers
22.9.2. Original MySQL API (Mysql)
22.9.3. MySQL Improved Extension (Mysqli)
22.9.4. MySQL Functions (PDO_MYSQL) (MySQL (PDO))
22.9.5. MySQL Native Driver (Mysqlnd)
22.9.6. Mysqlnd replication and load balancing plugin (mysqlnd_ms)
22.9.7. Mysqlnd query result cache plugin (mysqlnd_qc)
22.9.8. Mysqlnd user handler plugin (mysqlnd_uh)
22.9.9. Mysqlnd connection multiplexing plugin (mysqlnd_mux)
22.9.10. Mysqlnd Memcache plugin (mysqlnd_memcache)
22.9.11. Connector/PHP
22.9.12. Common Problems with MySQL and PHP
22.9.13. Enabling Both mysql and mysqli inPHP
22.10. MySQL Perl API
22.11. MySQL Python API
22.12. MySQL Ruby APIs
22.12.1. The MySQL/Ruby API
22.12.2. The Ruby/MySQL API
22.13. MySQL Tcl API
22.14. 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 ODBC, Java (JDBC), Perl, Python, PHP, Ruby, and native C and embedded MySQL instances.


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

MySQL Connectors

Oracle develops a number of connectors:


For direct access to using MySQL natively within a C application, there are two methods:

See also Section 22.8.1, "MySQL C API Implementations".

To access MySQL from a C application, or to build an interface to MySQL for a language not supported by the Connectors or APIs in this chapter, the C API is where to start. A number of programmer's utilities are available to help with the process; see Section 4.7, "MySQL Program Development Utilities".

Third-Party MySQL APIs

The remaining APIs described in this chapter provide an interface to MySQL from specific application languages. These third-party solutions are not developed or supported by Oracle. Basic information on their usage and abilities is provided here for reference purposes only.

All the third-party language APIs are developed using one of two methods, using libmysqlclient or by implementing a native driver. The two solutions offer different benefits:

Table 22.1, "MySQL APIs and Interfaces" lists many of the libraries and interfaces available for MySQL. Table 22.2, "MySQL Connector Versions and MySQL Server Versions" shows which MySQL Server versions each connector supports.

Table 22.1. MySQL APIs and Interfaces

Environment API Type Notes
Ada GNU Ada MySQL Bindings libmysqlclient See MySQL Bindings for GNU Ada
C C API libmysqlclient See Section 22.8, "MySQL C API".
C Connector/C Replacement for libmysqlclient See Section 22.5, "MySQL Connector/C".
C++ Connector/C++ libmysqlclient See Section 22.4, "MySQL Connector/C++".
MySQL++ libmysqlclient See MySQL++ Web site.
MySQL wrapped libmysqlclient See MySQL wrapped.
Cocoa MySQL-Cocoa libmysqlclient Compatible with the Objective-C Cocoa environment. See
D MySQL for D libmysqlclient See MySQL for D.
Eiffel Eiffel MySQL libmysqlclient See Section 22.14, "MySQL Eiffel Wrapper".
Erlang erlang-mysql-driver libmysqlclient See erlang-mysql-driver.
Haskell Haskell MySQL Bindings Native Driver See Brian O'Sullivan's pure Haskell MySQL bindings.
hsql-mysql libmysqlclient See MySQL driver for Haskell .
Java/JDBC Connector/J Native Driver See Section 22.3, "MySQL Connector/J".
Kaya MyDB libmysqlclient See MyDB.
Lua LuaSQL libmysqlclient See LuaSQL.
.NET/Mono Connector/Net Native Driver See Section 22.2, "MySQL Connector/Net".
Objective Caml OBjective Caml MySQL Bindings libmysqlclient See MySQL Bindings for Objective Caml.
Octave Database bindings for GNU Octave libmysqlclient See Database bindings for GNU Octave.
ODBC Connector/ODBC libmysqlclient See Section 22.1, "MySQL Connector/ODBC".
Perl DBI/DBD::mysql libmysqlclient See Section 22.10, "MySQL Perl API".
Net::MySQL Native Driver See Net::MySQL at CPAN
PHP mysql, ext/mysql interface (deprecated) libmysqlclient See Section 22.9.2, "Original MySQL API (Mysql)".
mysqli, ext/mysqli interface libmysqlclient See Section 22.9.3, "MySQL Improved Extension (Mysqli)".
PDO_MYSQL libmysqlclient See Section 22.9.4, "MySQL Functions (PDO_MYSQL) (MySQL (PDO))".
PDO mysqlnd Native Driver
Python Connector/Python Native Driver See Section 22.6, "MySQL Connector/Python".
MySQLdb libmysqlclient See Section 22.11, "MySQL Python API".
Ruby MySQL/Ruby libmysqlclient Uses libmysqlclient. See Section 22.12.1, "The MySQL/Ruby API".
Ruby/MySQL Native Driver See Section 22.12.2, "The Ruby/MySQL API".
Scheme Myscsh libmysqlclient See Myscsh.
SPL sql_mysql libmysqlclient See sql_mysqlfor SPL.
Tcl MySQLtcl libmysqlclient See Section 22.13, "MySQL Tcl API".

Table 22.2. MySQL Connector Versions and MySQL Server Versions

Connector Connector version MySQL Server version
Connector/C 6.1.0 GA 5.6, 5.5, 5.1, 5.0, 4.1
Connector/C++ 1.0.5 GA 5.6, 5.5, 5.1
Connector/J 5.1.8 5.6, 5.5, 5.1, 5.0, 4.1
Connector/Net 6.5 5.6, 5.5, 5.1, 5.0
Connector/Net 6.4 5.6, 5.5, 5.1, 5.0
Connector/Net 6.3 5.6, 5.5, 5.1, 5.0
Connector/Net 6.2 (No longer supported) 5.6, 5.5, 5.1, 5.0
Connector/Net 6.1 (No longer supported) 5.6, 5.5, 5.1, 5.0
Connector/Net 6.0 (No longer supported) 5.6, 5.5, 5.1, 5.0
Connector/Net 5.2 (No longer supported) 5.6, 5.5, 5.1, 5.0
Connector/Net 1.0 (No longer supported) 5.0, 4.0
Connector/ODBC 5.1 5.6, 5.5, 5.1, 5.0, 4.1.1+
Connector/ODBC 3.51 (Unicode not supported) 5.6, 5.5, 5.1, 5.0, 4.1 - all specs in one place