| Home | Libraries | People | FAQ | More

#### connection

(Legacy) A connection to a MySQL server.

##### Synopsis

Defined in header `<boost/mysql/connection.hpp>`

    template<
        class Stream>
    class connection;

##### Types

Name | Description
--- | ---
executor_type | The executor type associated to this object.
rebind_executor | Rebinds the connection type to another executor.
stream_type | The `Stream` type this connection is using.

##### Member Functions

Name | Description
--- | ---
async_close | Closes the connection to the server.
async_close_statement | Closes a statement, deallocating it from the server.
async_connect | Establishes a connection to a MySQL server.
async_execute | Executes a text query or prepared statement.
async_handshake | Performs the MySQL-level handshake.
async_ping | Checks whether the server is alive.
async_prepare_statement | Prepares a statement server-side.
async_quit | Notifies the MySQL server that the client wants to end the session and shutdowns SSL.
async_read_resultset_head | Reads metadata for subsequent resultsets in a multi-resultset operation.
async_read_some_rows | Reads a batch of rows.
async_reset_connection | Resets server-side session state, like variables and prepared statements.
async_start_execution | Starts a SQL execution as a multi-function operation.
close | Closes the connection to the server.
close_statement | Closes a statement, deallocating it from the server.
connect | Establishes a connection to a MySQL server.
connection [constructor] | Initializing constructor. — Initializing constructor with buffer params. — Move constructor.
execute | Executes a text query or prepared statement.
get_executor | Retrieves the executor associated to this object.
handshake | Performs the MySQL-level handshake.
meta_mode | Returns the current metadata mode that this connection is using.
operator= | Move assignment.
ping | Checks whether the server is alive.
prepare_statement | Prepares a statement server-side.
quit | Notifies the MySQL server that the client wants to end the session and shutdowns SSL.
read_resultset_head | Reads metadata for subsequent resultsets in a multi-resultset operation.
read_some_rows | Reads a batch of rows.
reset_connection | Resets server-side session state, like variables and prepared statements.
set_meta_mode | Sets the metadata mode.
start_execution | Starts a SQL execution as a multi-function operation.
stream | Retrieves the underlying Stream object.
uses_ssl | Returns whether the connection negotiated the use of SSL or not.

##### Description

Represents a templated connection to a MySQL server.

`connection` owns a `Stream` object that is accessed by functions involving network operations, as well as session state. You can access the stream using `connection::stream`, and its executor via `connection::get_executor`. The executor used by this object is always the same as the underlying stream.

##### Thread safety

Distinct objects: safe.

Shared objects: unsafe.

This class is not thread-safe: for a single object, if you call its member functions concurrently from separate threads, you will get a race condition.

##### Legacy

New code should use `any_connection` instead of this class, as it's simpler to use and provides the same level of performance.

Convenience header `<boost/mysql.hpp>`