SQL Relay C++ API

- Main Page
- Classes
- Files

- Class List
- Class Members

Public Member Functions
sqlrconnection Class Reference

List of all members.

## Public Member Functions
| sqlrconnection (const char *server, uint16_t port, const char *socket, const char *user, const char *password, int32_t retrytime, int32_t tries)
| ~sqlrconnection ()
void | setTimeout (int32_t timeoutsec, int32_t timeoutusec)
void | endSession ()
bool | suspendSession ()
uint16_t | getConnectionPort ()
const char * | getConnectionSocket ()
bool | resumeSession (uint16_t port, const char *socket)
bool | ping ()
const char * | identify ()
const char * | dbVersion ()
const char * | serverVersion ()
const char * | clientVersion ()
const char * | bindFormat ()
bool | selectDatabase (const char *database)
const char * | getCurrentDatabase ()
uint64_t | getLastInsertId ()
bool | autoCommitOn ()
bool | autoCommitOff ()
bool | commit ()
bool | rollback ()
const char * | errorMessage ()
void | debugOn ()
void | debugOff ()
bool | getDebug ()
void | debugPrintFunction (int(*printfunction)(const char *,...))

## Constructor & Destructor Documentation

sqlrconnection::sqlrconnection | ( | const char * | server,
|  | uint16_t | port,
|  | const char * | socket,
|  | const char * | user,
|  | const char * | password,
|  | int32_t | retrytime,
|  | int32_t | tries
| ) |  |

Initiates a connection to "server" on "port" or to the unix "socket" on the local machine and authenticates with "user" and "password". Failed connections will be retried for "tries" times on interval "retrytime". If "tries" is 0 then retries will continue forever. If "retrytime" is 0 then retries will be attempted on a default interval.

If the "socket" parameter is neither NULL nor "" then an attempt will be made to connect through it before attempting to connect to "server" on "port". If it is NULL or "" then no attempt will be made to connect through the socket.

sqlrconnection::~sqlrconnection | ( |  | ) |

Disconnects and ends the session if it hasn't been ended already.

## Member Function Documentation

bool sqlrconnection::autoCommitOff | ( |  | ) |

Instructs the database to wait for the client to tell it when to commit.

bool sqlrconnection::autoCommitOn | ( |  | ) |

Instructs the database to perform a commit after every successful query.

const char* sqlrconnection::bindFormat | ( |  | ) |

Returns a string representing the format of the bind variables used in the db.

const char* sqlrconnection::clientVersion | ( |  | ) |

Returns the version of the sqlrelay client software.

bool sqlrconnection::commit | ( |  | ) |

Issues a commit. Returns 1 if the commit succeeded, 0 if it failed.

const char* sqlrconnection::dbVersion | ( |  | ) |

Returns the version of the database

void sqlrconnection::debugOff | ( |  | ) |

Turns debugging off.

void sqlrconnection::debugOn | ( |  | ) |

Causes verbose debugging information to be sent to standard output. Another way to do this is to start a query with "-- debug\n". Yet another way is to set the environment variable SQLRDEBUG to "ON"

void sqlrconnection::debugPrintFunction | ( | int(*)(const char *,...) | printfunction | ) |

Allows you to replace the function used to print debug messages with your own function. The function is expected to take arguments like printf().

void sqlrconnection::endSession | ( |  | ) |

Ends the session.

const char* sqlrconnection::errorMessage | ( |  | ) |

If an operation failed and generated an error, the error message is available here. If there is no error then this method returns NULL.

uint16_t sqlrconnection::getConnectionPort | ( |  | ) |

Returns the inet port that the connection is communicating over. This parameter may be passed to another connection for use in the resumeSession() method. Note: The value this method returns is only valid after a call to suspendSession().

const char* sqlrconnection::getConnectionSocket | ( |  | ) |

Returns the unix socket that the connection is communicating over. This parameter may be passed to another connection for use in the resumeSession() method. Note: The value this method returns is only valid after a call to suspendSession().

const char* sqlrconnection::getCurrentDatabase | ( |  | ) |

Returns the database/schema that is currently in use.

bool sqlrconnection::getDebug | ( |  | ) |

Returns false if debugging is off and true if debugging is on.

uint64_t sqlrconnection::getLastInsertId | ( |  | ) |

Returns the value of the autoincrement column for the last insert

const char* sqlrconnection::identify | ( |  | ) |

Returns the type of database: oracle8, postgresql, mysql, etc.

bool sqlrconnection::ping | ( |  | ) |

Returns true if the database is up and false if it's down.

bool sqlrconnection::resumeSession | ( | uint16_t | port,
|  | const char * | socket
| ) |  |

Resumes a session previously left open using suspendSession(). Returns true on success and false on failure.

bool sqlrconnection::rollback | ( |  | ) |

Issues a rollback. Returns 1 if the rollback succeeded, 0 if it failed.

bool sqlrconnection::selectDatabase | ( | const char * | database | ) |

Sets the current database/schema to "database"

const char* sqlrconnection::serverVersion | ( |  | ) |

Returns the version of the sqlrelay server software.

void sqlrconnection::setTimeout | ( | int32_t | timeoutsec,
|  | int32_t | timeoutusec
| ) |  |

Sets the server connect timeout in seconds and milliseconds. Setting either parameter to -1 disables the timeout.

bool sqlrconnection::suspendSession | ( |  | ) |

Disconnects this connection from the current session but leaves the session open so that another connection can connect to it using resumeSession().