MySQL Connector/C++  2.0.4
MySQL connector library for C and C++ applications
Public Types | Public Member Functions | List of all members
SessionSettings Class Reference

Represents session options to be passed at XSession/NodeSession object creation. More...

Public Types

enum  Options {
  URI, HOST, PORT, USER,
  PWD, DB, SSL_ENABLE, SSL_CA
}
 Session creation options. More...
 

Public Member Functions

 SessionSettings (const string &uri)
 Create a session using connection string or URL. More...
 
 SessionSettings (const std::string &host, unsigned port, const string &user, const char *pwd=NULL, const string &db=string())
 Create session explicitly specifying session parameters. More...
 
 SessionSettings (const std::string &host, const string &user, const char *pwd=NULL, const string &db=string())
 Create session using the default port. More...
 
 SessionSettings (unsigned port, const string &user, const char *pwd=NULL, const string &db=string())
 Create session on localhost. More...
 
template<typename V , typename... R>
 SessionSettings (Options opt, V val, R &...rest)
 Create session using a list of session options. More...
 
Valueoperator[] (Options opt)
 SessionSetting operator and methods.
 

Detailed Description

Represents session options to be passed at XSession/NodeSession object creation.

SessionSettings can be constructed using URL string, common connect options (host, port, user, password, database) or with a list of SessionSettings::Options constants followed by option value (unless given option has no value, like SSL_ENABLE).

Examples:

SessionSettings from_url("mysqlx://user:pwd@host:port/db?ssl-enable");
SessionSettings from_options("host", port, "user", "pwd", "db");
SessionSettings from_option_list(
);

Member Enumeration Documentation

enum Options

Session creation options.

Note
Specifying SSL_CA option implies SSL_ENABLE.
Enumerator
URI 

connection URI or string

HOST 

DNS name of the host, IPv4 address or IPv6 address.

PORT 

X Plugin port to connect to.

USER 

user name

PWD 

password

DB 

default database

SSL_ENABLE 

use TLS connection

SSL_CA 

path to a PEM file specifying trusted root certificates

Constructor & Destructor Documentation

SessionSettings ( const string uri)
inline

Create a session using connection string or URL.

Connection sting has the form "user:pass\\\@host:port/?option&option", valid URL is like a connection string with a mysqlx:// prefix. Host is specified as either DNS name, IPv4 address of the form "nn.nn.nn.nn" or IPv6 address of the form "[nn:nn:nn:...]".

Possible connection options are:

  • ssl-enable : use TLS connection
  • ssl-ca=path : path to a PEM file specifying trusted root certificates

Specifying ssl-ca option implies ssl-enable.

SessionSettings ( const std::string &  host,
unsigned  port,
const string user,
const char *  pwd = NULL,
const string db = string() 
)
inline

Create session explicitly specifying session parameters.

Note
Session settings constructed this way request an SSL connection by default.
SessionSettings ( const std::string &  host,
const string user,
const char *  pwd = NULL,
const string db = string() 
)
inline

Create session using the default port.

Note
Session settings constructed this way request an SSL connection by default.
SessionSettings ( unsigned  port,
const string user,
const char *  pwd = NULL,
const string db = string() 
)
inline

Create session on localhost.

Note
Session settings constructed this way request an SSL connection by default.
SessionSettings ( Options  opt,
val,
R &...  rest 
)
inline

Create session using a list of session options.

The list of options consist of SessionSettings::Options constant identifying the option to set, followed by option value (unless not required, as in the case of SSL_ENABLE).

Example:

See also
SessionSettings::Options.

The documentation for this class was generated from the following file: