MySQL++
3.3.0
|
Specialization of Connection
for TCP/IP.
More...
#include <tcp_connection.h>
Public Member Functions | |
TCPConnection () | |
Create object without connecting it to the MySQL server. | |
TCPConnection (const char *addr, const char *db=0, const char *user=0, const char *password=0) | |
Create object and connect to database server over TCP/IP in one step. More... | |
TCPConnection (const TCPConnection &other) | |
Establish a new connection using the same parameters as an existing connection. More... | |
~TCPConnection () | |
Destroy object. | |
bool | connect (const char *addr=0, const char *db=0, const char *user=0, const char *password=0) |
Connect to database after object is created. More... | |
Public Member Functions inherited from mysqlpp::Connection | |
Connection (bool te=true) | |
Create object without connecting to the database server. More... | |
Connection (const char *db, const char *server=0, const char *user=0, const char *password=0, unsigned int port=0) | |
Create object and connect to database server in one step. More... | |
Connection (const Connection &other) | |
Establish a new connection using the same parameters as an existing connection. More... | |
virtual | ~Connection () |
Destroy object. | |
std::string | client_version () const |
Get version of library underpinning the current database driver. | |
bool | connected () const |
Returns true if connection was established successfully. More... | |
ulonglong | count_rows (const std::string &table) |
Returns the number of rows in a table. More... | |
bool | create_db (const std::string &db) |
Ask the database server to create a database. More... | |
void | disconnect () |
Drop the connection to the database server. | |
DBDriver * | driver () |
Returns a reference to the current database driver. | |
bool | drop_db (const std::string &db) |
Asks the database server to drop (destroy) a database. More... | |
int | errnum () |
Return last error number associated with this connection. | |
const char * | error () const |
Return error message for last error associated with this connection. More... | |
std::string | ipc_info () const |
Get information about the IPC connection to the database server. More... | |
bool | kill (unsigned long tid) const |
Kill a database server thread. More... | |
operator private_bool_type () const | |
Test whether any error has occurred within the object. More... | |
Connection & | operator= (const Connection &rhs) |
Copy an existing Connection object's state into this object. | |
bool | ping () |
"Pings" the database server More... | |
int | protocol_version () const |
Returns version number of the protocol the database driver uses to communicate with the server. | |
Query | query (const char *qstr=0) |
Return a new query object. More... | |
Query | query (const std::string &qstr) |
Return a new query object. More... | |
bool | select_db (const std::string &db) |
Change to a different database managed by the database server we are connected to. More... | |
std::string | server_version () const |
Get the database server's version string. | |
bool | set_option (Option *o) |
Sets a connection option. More... | |
bool | shutdown () |
Ask database server to shut down. | |
std::string | server_status () const |
Returns information about database server's status. | |
unsigned long | thread_id () |
Returns the database server's thread ID for this connection. More... | |
Public Member Functions inherited from mysqlpp::OptionalExceptions | |
OptionalExceptions (bool e=true) | |
Default constructor. More... | |
virtual | ~OptionalExceptions () |
Destroy object. | |
void | enable_exceptions () const |
Enable exceptions from the object. | |
void | disable_exceptions () const |
Disable exceptions from the object. | |
bool | throw_exceptions () const |
Returns true if exceptions are enabled. | |
Static Public Member Functions | |
static bool | parse_address (std::string &addr, unsigned int &port, std::string &error) |
Break the given TCP/IP address up into a separate address and port form. More... | |
Static Public Member Functions inherited from mysqlpp::Connection | |
static bool | thread_aware () |
Returns true if both MySQL++ and database driver we're using were compiled with thread awareness. | |
static void | thread_end () |
Tells the underlying database driver that this thread is done using the library. | |
static bool | thread_start () |
Tells the underlying database driver that the current thread is now using its services. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from mysqlpp::Connection | |
void | build_error_message (const char *core) |
Build an error message in the standard form used whenever one of the methods can't succeed because we're not connected to the database server. | |
void | copy (const Connection &other) |
Establish a new connection as a copy of an existing one. More... | |
bool | parse_ipc_method (const char *server, std::string &host, unsigned int &port, std::string &socket_name) |
Extract elements from the server parameter in formats suitable for passing to DBDriver::connect(). | |
Protected Member Functions inherited from mysqlpp::OptionalExceptions | |
void | set_exceptions (bool e) const |
Sets the exception state to a particular value. More... | |
Protected Attributes inherited from mysqlpp::Connection | |
std::string | error_message_ |
MySQL++ specific error, if any. | |
Specialization of Connection
for TCP/IP.
This class just simplifies the connection creation interface of Connection
. It does not add new functionality.
|
inline |
Create object and connect to database server over TCP/IP in one step.
addr | TCP/IP address of server, in either dotted quad form or as a host or domain name; may be followed by a colon and a port number or service name to override default port |
db | name of database to use |
user | user name to log in under, or 0 to use the user name the program is running under |
password | password to use when logging in |
BEWARE: These parameters are not in the same order as those in the corresponding constructor for Connection. This is a feature, not a bug. :)
|
inline |
Establish a new connection using the same parameters as an existing connection.
other | pre-existing connection to clone |
bool mysqlpp::TCPConnection::connect | ( | const char * | addr = 0 , |
const char * | db = 0 , |
||
const char * | user = 0 , |
||
const char * | password = 0 |
||
) |
Connect to database after object is created.
It's better to use the connect-on-create constructor if you can. See its documentation for the meaning of these parameters.
If you call this method on an object that is already connected to a database server, the previous connection is dropped and a new connection is established.
|
static |
Break the given TCP/IP address up into a separate address and port form.
Does some sanity checking on the address. Only intended to try and prevent library misuse, not ensure that the address can actually be used to contact a server.
It understands the following forms:
- 1.2.3.4
It also understands IPv6 addresses, but to avoid confusion between the colons they use and the colon separating the address part from the service/port part, they must be in RFC 2732 form. Example: [2010:836B:4179::836B:4179]:1234
addr | the address and optional port/service combo to check on input, and the verified address on successful return |
port | the port number (resolved from the service name if necessary) on successful return |
error | on false return, reason for failure is placed here |
Referenced by mysqlpp::Connection::parse_ipc_method().