SQL Relay C# API: SQLRClient.SQLRConnection Class Reference

SQL Relay C# API

- Main Page
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | List of all members
SQLRClient.SQLRConnection Class Reference

Inherits IDisposable.

## Public Member Functions
| SQLRConnection (String server, UInt16 port, String socket, String user, String password, Int32 retrytime, Int32 tries)
void | Dispose ()
void | setConnectTimeout (Int32 timeoutsec, Int32 timeoutusec)
void | setAuthenticationTimeout (Int32 timeoutsec, Int32 timeoutusec)
void | setResponseTimeout (Int32 timeoutsec, Int32 timeoutusec)
void | endSession ()
Boolean | suspendSession ()
UInt16 | getConnectionPort ()
String | getConnectionSocket ()
Boolean | resumeSession (UInt16 port, String socket)
Boolean | ping ()
String | identify ()
String | dbVersion ()
String | dbHostName ()
String | dbIpAddress ()
String | serverVersion ()
String | clientVersion ()
String | bindFormat ()
Boolean | selectDatabase (String database)
String | getCurrentDatabase ()
UInt64 | getLastInsertId ()
Boolean | autoCommitOn ()
Boolean | autoCommitOff ()
Boolean | begin ()
Boolean | commit ()
Boolean | rollback ()
String | errorMessage ()
Int64 | errorNumber ()
void | debugOn ()
void | debugOff ()
Boolean | getDebug ()
void | setDebugFile (String filename)
void | setClientInfo (String clientinfo)
String | getClientInfo ()
IntPtr | getInternalConnectionStructure ()

## Protected Member Functions
virtual void | Dispose (Boolean disposing)

## Constructor & Destructor Documentation

SQLRClient.SQLRConnection.SQLRConnection | ( | String | server,
|  | UInt16 | port,
|  | String | socket,
|  | String | user,
|  | String | password,
|  | Int32 | retrytime,
|  | Int32 | 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, waiting "retrytime" seconds between each try. 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 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.

## Member Function Documentation

Boolean SQLRClient.SQLRConnection.autoCommitOff | ( |  | ) |

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

Boolean SQLRClient.SQLRConnection.autoCommitOn | ( |  | ) |

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

Boolean SQLRClient.SQLRConnection.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.

String SQLRClient.SQLRConnection.bindFormat | ( |  | ) |

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

String SQLRClient.SQLRConnection.clientVersion | ( |  | ) |

Returns the version of the sqlrelay client software.

Boolean SQLRClient.SQLRConnection.commit | ( |  | ) |

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

String SQLRClient.SQLRConnection.dbHostName | ( |  | ) |

Returns the host name of the database

String SQLRClient.SQLRConnection.dbIpAddress | ( |  | ) |

Returns the ip address of the database

String SQLRClient.SQLRConnection.dbVersion | ( |  | ) |

Returns the version of the database

void SQLRClient.SQLRConnection.debugOff | ( |  | ) |

Turns debugging off.

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

void SQLRClient.SQLRConnection.endSession | ( |  | ) |

Ends the session.

String SQLRClient.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

Int64 SQLRClient.SQLRConnection.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.

String SQLRClient.SQLRConnection.getClientInfo | ( |  | ) |

Returns the string that was set by setClientInfo().

UInt16 SQLRClient.SQLRConnection.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().

String SQLRClient.SQLRConnection.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().

String SQLRClient.SQLRConnection.getCurrentDatabase | ( |  | ) |

Returns the database/schema that is currently in use.

Boolean SQLRClient.SQLRConnection.getDebug | ( |  | ) |

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

IntPtr SQLRClient.SQLRConnection.getInternalConnectionStructure | ( |  | ) |

Returns a pointer to the internal connection structure

UInt64 SQLRClient.SQLRConnection.getLastInsertId | ( |  | ) |

Returns the value of the autoincrement column for the last insert

String SQLRClient.SQLRConnection.identify | ( |  | ) |

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

Boolean SQLRClient.SQLRConnection.ping | ( |  | ) |

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

Boolean SQLRClient.SQLRConnection.resumeSession | ( | UInt16 | port,
|  | String | socket
| ) |  |

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

Boolean SQLRClient.SQLRConnection.rollback | ( |  | ) |

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

Boolean SQLRClient.SQLRConnection.selectDatabase | ( | String | database | ) |

Sets the current database/schema to "database"

String SQLRClient.SQLRConnection.serverVersion | ( |  | ) |

Returns the version of the sqlrelay server software.

void SQLRClient.SQLRConnection.setAuthenticationTimeout | ( | Int32 | timeoutsec,
|  | Int32 | timeoutusec
| ) |  |

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

void SQLRClient.SQLRConnection.setClientInfo | ( | String | 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.

void SQLRClient.SQLRConnection.setConnectTimeout | ( | Int32 | timeoutsec,
|  | Int32 | 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.

void SQLRClient.SQLRConnection.setDebugFile | ( | String | filename | ) |

Allows you to specify a file to write debug to. Setting "filename" to NULL or an empty string causes debug to be written to standard output (the default).

void SQLRClient.SQLRConnection.setResponseTimeout | ( | Int32 | timeoutsec,
|  | Int32 | timeoutusec
| ) |  |

Sets the response timeout (for queries, commits, rollbacks, pings, etc.) in seconds and milliseconds. Setting either parameter to -1 disables the timeout. You can also set this timeout using the SQLR_CLIENT_RESPONSE_TIMEOUT environment variable.

Boolean SQLRClient.SQLRConnection.suspendSession | ( |  | ) |

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