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

### Methods

autoCommitOff autoCommitOn bindFormat clientVersion commit dbVersion debugOff debugOn endSession errorMessage getConnectionPort getConnectionSocket getCurrentDatabase getDebug getLastInsertId identify new ping resumeSession rollback selectDatabase serverVersion setTimeout 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.

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 1 if the commit succeeded, 0 if it failed and -1 if an error occurred.

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 SQLRDEBUG 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

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: oracle8, 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 1 if the rollback succeeded, 0 if it failed and -1 if an error occurred.

selectDatabase(database)

Sets the current database/schema to "database"

serverVersion()

Returns the version of the sqlrelay server software.

setTimeout(timeoutsec,timeoutusec)

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

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]