Class | SQLRConnection
In: | sqlrelay.cpp
Parent: | Object

### Methods

autoCommitOff autoCommitOn begin bindFormat clientVersion commit dbHostName dbIpAddress dbVersion debugOff debugOn endSession errorMessage errorNumber getClientInfo getConnectionPort getConnectionSocket getCurrentDatabase getDebug getLastInsertId identify new ping resumeSession rollback selectDatabase serverVersion setClientInfo setConnectTimeout suspendSession

### Public Class methods

new(host, port, socket, user, password, retrytime, tries)

Initiates a connection to "host" 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 nether nil nor "" then an attempt will be made to connect through it before attempting to connect to "host" on "port". If it is nil or "" then no attempt will be made to connect through the socket.

### Public Instance methods

autoCommitOff()

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

autoCommitOn()

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

begin()

Begins a transaction. Returns true if the begin succeeded, false if it failed. If the database automatically begins a new transaction when a commit or rollback is issued then this doesn‘t do anything unless SQL Relay is faking transaction blocks.

bindFormat()

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

clientVersion()

Returns the version of the sqlrelay client software.

commit()

Issues a commit. Returns true if the commit succeeded, false if it failed.

dbHostName()

Returns the host name of the database

dbIpAddress()

Returns the ip address of the database

dbVersion()

Returns the version of the database

debugOff()

Turns debugging off.

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 SQLR_CLIENT_DEBUG to "ON"

endSession()

Ends the session.

errorMessage()

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

errorNumber()

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

getClientInfo()

Returns the string that was set by setClientInfo().

getConnectionPort()

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

getConnectionSocket()

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

getCurrentDatabase()

Returns the database/schema that is currently in use.

getDebug()

Returns 0 if debugging is off and 1 if debugging is on.

getLastInsertId()

Returns the value of the autoincrement column for the last insert

identify()

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

ping()

Returns 1 if the database is up and 0 if it‘s down.

resumeSession(port,socket)

Resumes a session previously left open using sqlrcon_suspendSession(). Returns 1 on success and 0 on failure.

rollback()

Issues a rollback. Returns true if the rollback succeeded, false if it failed.

selectDatabase(database)

Sets the current database/schema to "database"

serverVersion()

Returns the version of the sqlrelay server software.

setClientInfo(clientinfo)

Allows you to set a string that will be passed to the server and ultimately included in server-side logging along with queries that were run by this instance of the client.

setConnectTimeout(timeoutsec,timeoutusec)

Sets the server connect timeout in seconds and milliseconds. Setting either parameter to -1 disables the timeout. You can also set this timeout using the SQLR_CLIENT_CONNECT_TIMEOUT environment variable.

suspendSession()

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

[Validate]