#include <Ccdb_Connection.h>
Public Member Functions | |
virtual | ~Connection () |
dtRtnStatus | Begin () |
dtRtnStatus | Close () |
dtRtnStatus | Commit () |
dtRtnStatus | Connect (const dtSTRING *, const dtSTRING *=NULL, const dtSTRING *=NULL, const dtSTRING *=NULL, const dtSTRING *=NULL, const dtSTRING *=NULL) |
Statement * | CreateStatement () |
Statement * | CreateStatement (const dtSTRING *) |
const dtSTRING * | GetCatalogName () |
DatabaseMetaData * | GetDatabaseMetaData () |
const dtSTRING * | GetDataSourceName () |
dtULARGE | GetFetchSize () |
Navigation * | GetNavigationInstance () |
const dtSTRING * | GetPurposeName () |
const dtSTRING * | GetRecipientID () |
Statement * | GetStatement (const dtLARGE) |
Statement * | GetStatement (const dtSTRING *) |
const dtSTRING * | GetServerName () |
const dtSTRING * | GetServiceName () |
const dtSTRING * | GetUserID () |
const dtBOOLEAN | IsAutoCommitEnabled () |
const dtBOOLEAN | IsClosed () |
const dtBOOLEAN | IsCompressionEnabled () |
const dtBOOLEAN | IsDefaultSynonymsEnabled () |
const dtBOOLEAN | IsFlatDefinitionsEnabled () |
const dtBOOLEAN | IsNetworkTypesEnabled () |
const dtBOOLEAN | IsReadOnly () |
const dtBOOLEAN | IsValid () |
dtRtnStatus | Reconnect () |
void | Reset () |
dtRtnStatus | Rollback () |
dtRtnStatus | SetAutoStartTransact (const dtBOOLEAN) |
dtRtnStatus | SetCatalog (const dtSTRING *) |
dtRtnStatus | SetEnableAutoCommit (const dtBOOLEAN) |
dtRtnStatus | SetEnableDefaultSynonym (const dtBOOLEAN) |
dtRtnStatus | SetEnableFlatDefinitions (const dtBOOLEAN) |
dtRtnStatus | SetEnableNetworkTypes (const dtBOOLEAN) |
dtRtnStatus | SetEnableReadOnly (const dtBOOLEAN) |
dtRtnStatus | SetFetchSize (dtULARGE) |
void | SetPassword (const dtSTRING *) |
void | SetProgramName (const dtSTRING *) |
dtRtnStatus | SetPurposeName (const dtSTRING *) |
dtRtnStatus | SetRecipientID (const dtSTRING *) |
void | SetTimeout (const dtULARGE period) |
void | SetUserID (const dtSTRING *) |
Public Member Functions inherited from dbSpaces::dbcli::cdbBase | |
cdbBase (cdbBase *, ccdbClassType, dtBOOLEAN=TRUE) | |
virtual | ~cdbBase () |
cdb_childList_t & | GetChildList () |
Ccoms_CommsManager * | GetTransportComms () |
ccdbClassType | GetType () |
void | SetTransportComms (Ccoms_CommsManager *) |
Protected Member Functions | |
Connection (Environment *) | |
A Connection represents a session with a specific database.
Within the context of a Connection, SQL statements can be executed with potentially result sets being returned, or Navigational (NO-SQL) requests can be executed for retrieving, inserting, deleting and updating rows.
A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. This information is obtained with the getMetaData method.
Note: By default the Connection automatically commits changes after executing each statement. If auto commit has been disabled, an explicit commit must be done or database changes will not be saved.
A DatabaseException will be thrown if a database error occurs and exceptions are enabled. If exceptions are not enabled the following error methods can be used to get information about the error;
|
protected |
Connection default constructor.
environment | The Environment object. |
|
virtual |
Connection default destructor.
dtRtnStatus dbSpaces::dbcli::Connection::Begin | ( | ) |
Start a new transaction.
DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::Close | ( | ) |
Close the connection to the server. Close will also close any open Statements, ResultSet and Navigation objects. If there are any active transactions they will be rolled back if they have not been already committed.
DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::Commit | ( | ) |
Commit makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection. This method should only be used when auto commit has been disabled.
DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::Connect | ( | const dtSTRING * | , |
const dtSTRING * | = NULL , |
||
const dtSTRING * | = NULL , |
||
const dtSTRING * | = NULL , |
||
const dtSTRING * | = NULL , |
||
const dtSTRING * | = NULL |
||
) |
Make a connection to the database server using the Data Source name provided.
For more information on network Services see the dbSpaces Config program.
The connection credentials are made up using; userID, password, Purpose name, and Recipient ID and override the values assoicated with the Data Source.
dataSourceName | Data source name. |
userID | User ID to use (Overrides the Data source User ID value). |
password | User password to use (Overrides the Data source Password value). |
purposeName | Purpose name to use (Overrides the Data source Purpose value). |
recipientID | Recipient ID to use (Overrides the Data source Recipient ID value). |
catalogName | Catalog name (Overrides the Data source Catalog value). |
DatabaseException | (if exceptions are enabled) when a database error occurs. |
Statement * dbSpaces::dbcli::Connection::CreateStatement | ( | ) |
Statement * dbSpaces::dbcli::Connection::CreateStatement | ( | const dtSTRING * | ) |
const dtSTRING * dbSpaces::dbcli::Connection::GetCatalogName | ( | ) |
Get the current Catalog name for the connection.
DatabaseMetaData * dbSpaces::dbcli::Connection::GetDatabaseMetaData | ( | ) |
Get the DatabaseMetaData object for the connection.
DatabaseException | (if exceptions are enabled) when a database error occurs. |
const dtSTRING * dbSpaces::dbcli::Connection::GetDataSourceName | ( | ) |
Get the name of the Data Source used by the connection. Data Sources are used to define the method of communicating with the server.
dtULARGE dbSpaces::dbcli::Connection::GetFetchSize | ( | ) |
Get the fetch size for returning rows with the ResultSet object.
Navigation * dbSpaces::dbcli::Connection::GetNavigationInstance | ( | ) |
Get the Navigation object for the connection. The Navigation object allows NO-SQL access to tables in the database.
DatabaseException | (if exceptions are enabled) when a database error occurs. |
const dtSTRING * dbSpaces::dbcli::Connection::GetPurposeName | ( | ) |
Get the Purpose name for the connection.
const dtSTRING * dbSpaces::dbcli::Connection::GetRecipientID | ( | ) |
Get the Recipient ID for the connection.
const dtSTRING * dbSpaces::dbcli::Connection::GetServerName | ( | ) |
Get the local server name for the connection.
DatabaseException | (if exceptions are enabled) when a database error occurs |
const dtSTRING * dbSpaces::dbcli::Connection::GetServiceName | ( | ) |
Get the name of the Service used by the connection. Services are used to define the method of communicating with the server by the Data Source.
Statement * dbSpaces::dbcli::Connection::GetStatement | ( | const | dtLARGE | ) |
Statement * dbSpaces::dbcli::Connection::GetStatement | ( | const dtSTRING * | ) |
const dtSTRING * dbSpaces::dbcli::Connection::GetUserID | ( | ) |
Get the User ID that was used to connect to the server.
const dtBOOLEAN dbSpaces::dbcli::Connection::IsAutoCommitEnabled | ( | ) |
Check if auto-commit is enabled.
TRUE
if is enabled; FALSE
if otherwise. const dtBOOLEAN dbSpaces::dbcli::Connection::IsClosed | ( | ) |
Check if the connection to the server is closed.
TRUE
if closed; FALSE
if otherwise. const dtBOOLEAN dbSpaces::dbcli::Connection::IsCompressionEnabled | ( | ) |
Check if compression is enabled? If compression is enabled then size of data packets sent to the server is reduced.
TRUE
if is enabled; FALSE
if otherwise. const dtBOOLEAN dbSpaces::dbcli::Connection::IsDefaultSynonymsEnabled | ( | ) |
Check if default synonym is enabled? If default synonyms are enabled then they will be used instead of column names.
TRUE
if is enabled; FALSE
if otherwise. const dtBOOLEAN dbSpaces::dbcli::Connection::IsFlatDefinitionsEnabled | ( | ) |
Check if flat definitions are enabled? If flat definitions are enabled then they are used to get and set column data.
TRUE
if is enabled; FALSE
if otherwise. const dtBOOLEAN dbSpaces::dbcli::Connection::IsNetworkTypesEnabled | ( | ) |
Check if network data types are enabled. The standard for sending data across the network is high-low endian. If your client is of the same byte order as the server network data types do not need to be enabled which helps with performance.
TRUE
if is enabled; FALSE
if otherwise. const dtBOOLEAN dbSpaces::dbcli::Connection::IsReadOnly | ( | ) |
Check if the connection is read-only. If the connection has been set to read-only then any request other then a read will produce an error.
TRUE
if read-only; FALSE
if otherwise. const dtBOOLEAN dbSpaces::dbcli::Connection::IsValid | ( | ) |
Check if the connection is still valid and not been lost.
TRUE
if still valid; FALSE
if otherwise. DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::Reconnect | ( | ) |
Reconnect if the connection has been closed.
DatabaseException | (if exceptions are enabled) when a database error occurs. |
void dbSpaces::dbcli::Connection::Reset | ( | ) |
Reset connection state.
dtRtnStatus dbSpaces::dbcli::Connection::Rollback | ( | ) |
Rolls back the work of an existing transaction.
DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::SetAutoStartTransact | ( | const | dtBOOLEAN | ) |
Set auto start a transaction state.
enable | TRUE to enable option, FALSE if otherwise (the default). |
DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::SetCatalog | ( | const dtSTRING * | ) |
Set the active Catalog for the connection.
When setting the active catalog the current properties for the UserID, Password, Purpose Name and RecipientID will be used for authentication to the database.
catalogName | The name of the catalog to use. |
DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::SetEnableAutoCommit | ( | const | dtBOOLEAN | ) |
If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements/Navigation requests are grouped into transactions that are terminated by either Commit() or Rollback(). By default, new connections are in auto-commit mode.
The commit occurs when the statement completes or the next execute occurs, whichever comes first. In the case of statements returning a ResultSet, the statement completes when the last row of the ResultSet has been retrieved or the ResultSet has been closed. In advanced cases, a single statement may return multiple results as well as output parameter values. Here the commit occurs when all results and output parameter values have been retrieved.
If caching has been enabled then any outstanding Navigation requests are flushed to the database and then the commit occurs.
enable | TRUE to enable auto-commit; FALSE if otherwise. |
DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::SetEnableDefaultSynonym | ( | const | dtBOOLEAN | ) |
Set use default synonyms and not a table's column names.
enable | TRUE use default synonyms, FALSE if otherwise (default). |
DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::SetEnableFlatDefinitions | ( | const | dtBOOLEAN | ) |
Set use flat definitions and not the table's real definitions
enable | TRUE use flat definitions, FALSE if otherwise (default). |
DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::SetEnableNetworkTypes | ( | const | dtBOOLEAN | ) |
Set use network data types. Network data types are in High/Low byte order.
enable | TRUE use network data types(default); FALSE if otherwise. |
DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::SetEnableReadOnly | ( | const | dtBOOLEAN | ) |
You can put a connection in read-only mode as a hint to enable database optimizations.
Note: SetEnableReadOnly cannot be called while in the middle of a transaction.
enable | TRUE enables read-only mode; FALSE disables read-only mode (default). |
DatabaseException | (if exceptions are enabled) when a database error occurs. |
dtRtnStatus dbSpaces::dbcli::Connection::SetFetchSize | ( | dtULARGE | ) |
Set the fetch size for the number of rows returned from a ResultSet or NavigationTable.
size | The new fetch size. |
DatabaseException | (if exceptions are enabled) when a database error occurs. |
void dbSpaces::dbcli::Connection::SetPassword | ( | const dtSTRING * | ) |
Set the user password for the User ID.
Setting the password should be set before reconnecting or the set catalog call.
password | The password for the User ID. |
void dbSpaces::dbcli::Connection::SetProgramName | ( | const dtSTRING * | ) |
Set the program name to identify the connection by in the server.
name | The Program name. |
dtRtnStatus dbSpaces::dbcli::Connection::SetPurposeName | ( | const dtSTRING * | ) |
Set the Purpose name for the connection.
Setting the Purpose name should be set before a connection, reconnection or the set catalog call.
If the Hippocratic Security addon is not licensed or not enabled for the database, the Purpose name is ignored.
name | The Purpose name. |
dtRtnStatus dbSpaces::dbcli::Connection::SetRecipientID | ( | const dtSTRING * | ) |
Set the Recipient ID for the connection.
Setting the Recipient ID should be set before a connection, reconnection or the set catalog call.
If the Hippocratic Security addon is not licensed or not enabled for the database, the Recipient ID is ignored.
recipientID | The Recipient ID. |
void dbSpaces::dbcli::Connection::SetTimeout | ( | const dtULARGE | period | ) |
Set the time out period when connecting to the server.
period | The number of seconds before timing out. |
void dbSpaces::dbcli::Connection::SetUserID | ( | const dtSTRING * | ) |
Set the User ID for the connection. Setting the User ID should be set before a connection, reconnection or set catalog call.
UserID | The User ID. |