OCILIB (C and C++ Driver for Oracle)
4.7.5
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
|
A connection or session with a specific database. More...
#include <types.hpp>
Inherits ocilib::core::HandleHolder< OCI_Connection * >.
Public Types | |
enum | TimeoutTypeValues { TimeoutSend = OCI_NTO_SEND , TimeoutReceive = OCI_NTO_RECEIVE , TimeoutCall = OCI_NTO_CALL } |
Timeout enumerated values. More... | |
enum | FailoverRequestValues { FailoverRequestSession = OCI_FOT_SESSION , FailoverRequestSelect = OCI_FOT_SELECT } |
Failover request enumerated values. More... | |
enum | FailoverEventValues { FailoverEventEnd = OCI_FOE_END , FailoverEventAbort = OCI_FOE_ABORT , FailoverEventReauthentificate = OCI_FOE_REAUTH , FailoverEventBegin = OCI_FOE_BEGIN , FailoverEventError = OCI_FOE_ERROR } |
Failover events enumerated values. More... | |
enum | FailoverResultValues { FailoverOk = OCI_FOC_OK , FailoverRetry = OCI_FOC_RETRY } |
Failover callback results enumerated values. More... | |
enum | SessionTraceValues { TraceIdentity = OCI_TRC_IDENTITY , TraceModule = OCI_TRC_MODULE , TraceAction = OCI_TRC_ACTION , TraceDetail = OCI_TRC_DETAIL } |
Session trace enumerated values. More... | |
typedef core::Enum< TimeoutTypeValues > | TimeoutType |
Timeout Types. | |
typedef core::Enum< FailoverRequestValues > | FailoverRequest |
Failover requests. | |
typedef core::Enum< FailoverEventValues > | FailoverEvent |
Failover events. | |
typedef core::Enum< FailoverResultValues > | FailoverResult |
Failover callback results. | |
typedef core::Enum< SessionTraceValues > | SessionTrace |
Session traces. | |
typedef FailoverResult(* | TAFHandlerProc) (Connection &con, FailoverRequest failoverRequest, FailoverEvent failoverEvent) |
User callback for TAF event notifications. | |
Public Member Functions | |
Connection () | |
Default constructor. | |
Connection (const ostring &db, const ostring &user, const ostring &pwd, Environment::SessionFlags sessionFlags=Environment::SessionDefault) | |
Constructor that creates an opens an underlying DB connection with the given information. | |
void | Open (const ostring &db, const ostring &user, const ostring &pwd, Environment::SessionFlags sessionFlags=Environment::SessionDefault) |
Create a physical connection to an Oracle database server. | |
void | Close () |
Close the physical connection to the DB server. | |
void | Commit () |
Commit current pending changes. | |
void | Rollback () |
Cancel current pending changes. | |
void | Break () |
Perform an immediate abort of any currently Oracle OCI call on the given connection. | |
void | SetAutoCommit (bool enabled) |
Enable or disable auto commit mode (implicit commits after every SQL execution) | |
bool | GetAutoCommit () const |
Indicates if auto commit is currently activated. | |
bool | IsServerAlive () const |
Indicate if the connection is still connected to the server. | |
bool | PingServer () const |
Performs a round trip call to the server to confirm that the connection to the server is still valid. | |
ostring | GetConnectionString () const |
Return the name of the connected database/service name. | |
ostring | GetUserName () const |
Return the current logged user name. | |
ostring | GetPassword () const |
Return the current logged user password. | |
ostring | GetServerVersion () const |
Return the connected database server string version. | |
OracleVersion | GetVersion () const |
Return the Oracle version supported by the connection. | |
unsigned int | GetServerMajorVersion () const |
Return the major version number of the connected database server. | |
unsigned int | GetServerMinorVersion () const |
Return the minor version number of the connected database server. | |
unsigned int | GetServerRevisionVersion () const |
Return the revision version number of the connected database server. | |
void | ChangePassword (const ostring &newPwd) |
Change the password of the logged user. | |
ostring | GetSessionTag () const |
Return the tag associated with the given connection. | |
void | SetSessionTag (const ostring &tag) |
Associate a tag to the given connection/session. | |
Transaction | GetTransaction () const |
Return the current transaction of the connection. | |
void | SetTransaction (const Transaction &transaction) |
Set a transaction to a connection. | |
bool | SetFormat (FormatType formatType, const ostring &format) |
Set the format string for implicit string conversions of the given type. | |
ostring | GetFormat (FormatType formatType) |
Return the format string for implicit string conversions of the given type. | |
void | EnableServerOutput (unsigned int bufsize, unsigned int arrsize, unsigned int lnsize) |
Enable the server output. | |
void | DisableServerOutput () |
Disable the server output. | |
bool | GetServerOutput (ostring &line) const |
Retrieve one line of the server buffer. | |
void | GetServerOutput (std::vector< ostring > &lines) const |
Retrieve all remaining lines of the server buffer. | |
void | SetTrace (SessionTrace trace, const ostring &value) |
Set tracing information for the session. | |
ostring | GetTrace (SessionTrace trace) const |
Get the current trace for the trace type from the given connection. | |
ostring | GetDatabase () const |
Return the Oracle server database name of the connected database/service name. | |
ostring | GetInstance () const |
Return the Oracle server Instance name of the connected database/service name. | |
ostring | GetService () const |
Return the Oracle server Service name of the connected database/service name. | |
ostring | GetServer () const |
Return the Oracle server Hos name of the connected database/service name. | |
ostring | GetDomain () const |
Return the Oracle server Domain name of the connected database/service name. | |
Timestamp | GetInstanceStartTime () const |
Return the date and time (Timestamp) server instance start of the. | |
unsigned int | GetStatementCacheSize () const |
Return the maximum number of statements to keep in the statement cache. | |
void | SetStatementCacheSize (unsigned int value) |
Set the maximum number of statements to keep in the statement cache. | |
unsigned int | GetDefaultLobPrefetchSize () const |
Return the default LOB prefetch buffer size for the connection. | |
void | SetDefaultLobPrefetchSize (unsigned int value) |
Enable or disable pre-fetching for all LOBs fetched in the connection. | |
unsigned int | GetMaxCursors () const |
Return the maximum number of SQL statements that can be opened in one session. | |
bool | IsTAFCapable () const |
Verify if the connection support TAF events. | |
void | SetTAFHandler (TAFHandlerProc handler) |
Set the Transparent Application Failover (TAF) user handler. | |
AnyPointer | GetUserData () |
Return the pointer to user data previously associated with the connection. | |
void | SetUserData (AnyPointer value) |
Associate a pointer to user data to the given connection. | |
unsigned int | GetTimeout (TimeoutType timeout) |
Returns the requested timeout value for OCI calls that require server round-trips to the given database. | |
void | SetTimeout (TimeoutType timeout, unsigned int value) |
Set a given timeout for OCI calls that require server round-trips to the given database. | |
A connection or session with a specific database.
This class wraps the OCILIB object handle OCI_Connection and its related methods
Failover requests.
Possible values are Connection::FailoverRequestValues
Failover events.
Possible values are Connection::FailoverEventValues
Failover callback results.
Possible values are Connection::FailoverResultValues
Session traces.
Possible values are Connection::SessionTraceValues
ocilib::Connection::TAFHandlerProc |
Timeout enumerated values.
Failover events enumerated values.
Session trace enumerated values.
|
inline |
Default constructor.
Definition at line 33 of file Connection.hpp.
|
inline |
Constructor that creates an opens an underlying DB connection with the given information.
db | - Oracle Service Name |
user | - Oracle User name |
pwd | - Oracle User password |
sessionFlags | - Session Flags |
Definition at line 38 of file Connection.hpp.
References Open().
|
inline |
Create a physical connection to an Oracle database server.
db | - Oracle Service Name |
user | - Oracle User name |
pwd | - Oracle User password |
sessionFlags | - Session Flags |
The XA connection string used in a transaction monitor to connect to Oracle must be compatible with OCILIB :
Definition at line 48 of file Connection.hpp.
References ocilib::core::Check(), and OCI_ConnectionCreate().
Referenced by Connection().
|
inline |
Close the physical connection to the DB server.
Definition at line 57 of file Connection.hpp.
|
inline |
Commit current pending changes.
Definition at line 62 of file Connection.hpp.
References ocilib::core::Check(), and OCI_Commit().
|
inline |
Cancel current pending changes.
Definition at line 67 of file Connection.hpp.
References ocilib::core::Check(), and OCI_Rollback().
|
inline |
Perform an immediate abort of any currently Oracle OCI call on the given connection.
Definition at line 72 of file Connection.hpp.
References ocilib::core::Check(), and OCI_Break().
|
inline |
Enable or disable auto commit mode (implicit commits after every SQL execution)
enabled | - auto commit new status |
Definition at line 77 of file Connection.hpp.
References ocilib::core::Check(), and OCI_SetAutoCommit().
|
inline |
Indicates if auto commit is currently activated.
Definition at line 82 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetAutoCommit().
|
inline |
Indicate if the connection is still connected to the server.
Definition at line 87 of file Connection.hpp.
References ocilib::core::Check(), and OCI_IsConnected().
|
inline |
Performs a round trip call to the server to confirm that the connection to the server is still valid.
Definition at line 92 of file Connection.hpp.
References ocilib::core::Check(), and OCI_Ping().
|
inline |
Return the name of the connected database/service name.
Definition at line 97 of file Connection.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetDatabase().
|
inline |
Return the current logged user name.
Definition at line 102 of file Connection.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetUserName().
|
inline |
Return the current logged user password.
Definition at line 107 of file Connection.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetPassword().
|
inline |
Return the connected database server string version.
Definition at line 117 of file Connection.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetVersionServer().
|
inline |
Return the Oracle version supported by the connection.
Definition at line 112 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetVersionConnection().
|
inline |
Return the major version number of the connected database server.
Definition at line 122 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetServerMajorVersion().
|
inline |
Return the minor version number of the connected database server.
Definition at line 127 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetServerMinorVersion().
|
inline |
Return the revision version number of the connected database server.
Definition at line 132 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetServerRevisionVersion().
|
inline |
Change the password of the logged user.
newPwd | - New password |
Definition at line 137 of file Connection.hpp.
References ocilib::core::Check(), and OCI_SetPassword().
|
inline |
Return the tag associated with the given connection.
Definition at line 142 of file Connection.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetSessionTag().
|
inline |
Associate a tag to the given connection/session.
tag | - user tag string |
Definition at line 147 of file Connection.hpp.
References ocilib::core::Check(), and OCI_SetSessionTag().
|
inline |
Return the current transaction of the connection.
Definition at line 152 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetTransaction().
|
inline |
Set a transaction to a connection.
transaction | - Transaction to assign |
Definition at line 157 of file Connection.hpp.
References ocilib::core::Check(), and OCI_SetTransaction().
|
inline |
Set the format string for implicit string conversions of the given type.
formatType | - Type of format |
format | - Format string |
Formats can set at 2 levels:
When the library needs to perform a string conversion, it search for a valid format using the following order:
Definition at line 162 of file Connection.hpp.
References ocilib::core::Check(), and OCI_SetFormat().
|
inline |
Return the format string for implicit string conversions of the given type.
formatType | - Type of format |
Definition at line 167 of file Connection.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetFormat().
|
inline |
Enable the server output.
bufsize | - server buffer max size (server side) |
arrsize | - number of lines to retrieve per server round-trip |
lnsize | - maximum size of one line |
Definition at line 172 of file Connection.hpp.
References ocilib::core::Check(), and OCI_ServerEnableOutput().
|
inline |
Disable the server output.
Definition at line 177 of file Connection.hpp.
References ocilib::core::Check(), and OCI_ServerDisableOutput().
|
inline |
Retrieve one line of the server buffer.
Definition at line 182 of file Connection.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_ServerGetOutput().
|
inline |
Retrieve all remaining lines of the server buffer.
Definition at line 191 of file Connection.hpp.
References ocilib::core::Check(), and OCI_ServerGetOutput().
|
inline |
Set tracing information for the session.
trace | - trace type |
value | - trace content |
Store current trace information to the given connection handle. These information:
system view V$SESSION
Definition at line 202 of file Connection.hpp.
References ocilib::core::Check(), and OCI_SetTrace().
|
inline |
Get the current trace for the trace type from the given connection.
trace | - trace type |
Definition at line 207 of file Connection.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetTrace().
|
inline |
Return the Oracle server database name of the connected database/service name.
Definition at line 212 of file Connection.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetDBName().
|
inline |
Return the Oracle server Instance name of the connected database/service name.
Definition at line 217 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetInstanceName().
|
inline |
Return the Oracle server Service name of the connected database/service name.
Definition at line 222 of file Connection.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetServiceName().
|
inline |
Return the Oracle server Hos name of the connected database/service name.
Definition at line 227 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetServerName().
|
inline |
Return the Oracle server Domain name of the connected database/service name.
Definition at line 232 of file Connection.hpp.
References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_GetDomainName().
|
inline |
Return the date and time (Timestamp) server instance start of the.
Definition at line 237 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetInstanceStartTime().
|
inline |
Return the maximum number of statements to keep in the statement cache.
Definition at line 242 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetStatementCacheSize().
|
inline |
Set the maximum number of statements to keep in the statement cache.
value | - maximum number of statements in the cache |
Definition at line 247 of file Connection.hpp.
References ocilib::core::Check(), and OCI_SetStatementCacheSize().
|
inline |
Return the default LOB prefetch buffer size for the connection.
Definition at line 252 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetDefaultLobPrefetchSize().
|
inline |
Enable or disable pre-fetching for all LOBs fetched in the connection.
value | - default prefetch buffer size |
Definition at line 257 of file Connection.hpp.
References ocilib::core::Check(), and OCI_SetDefaultLobPrefetchSize().
|
inline |
Return the maximum number of SQL statements that can be opened in one session.
Definition at line 262 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetMaxCursors().
|
inline |
Verify if the connection support TAF events.
Definition at line 267 of file Connection.hpp.
References ocilib::core::Check(), and OCI_IsTAFCapable().
|
inline |
Set the Transparent Application Failover (TAF) user handler.
handler | - TAF handler procedure |
Definition at line 272 of file Connection.hpp.
References ocilib::core::Check(), and OCI_SetTAFHandler().
|
inline |
Return the pointer to user data previously associated with the connection.
Definition at line 279 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetUserData().
|
inline |
Associate a pointer to user data to the given connection.
value | - User data pointer |
Definition at line 284 of file Connection.hpp.
References ocilib::core::Check(), and OCI_SetUserData().
|
inline |
Returns the requested timeout value for OCI calls that require server round-trips to the given database.
timeout | - Type of timeout |
Definition at line 289 of file Connection.hpp.
References ocilib::core::Check(), and OCI_GetTimeout().
|
inline |
Set a given timeout for OCI calls that require server round-trips to the given database.
timeout | - Type of timeout to set |
value | - Timeout in milliseconds |
OCI client raises an timeout type related error when a given timeout is reached.
Here is a summary:
FLAG | Min. Version | OCI Error raised | OCI Error description | sqlnet.ora equivalent |
---|---|---|---|---|
TimeoutSend | OCI_12_1 | ORA-12608 | TNS: Send timeout occurred | SQLNET.SEND_TIMEOUT |
TimeoutReceive | OCI_12_1 | ORA-12609 | TNS: Receive timeout occurred | SQLNET.RECV_TIMEOUT |
TimeoutCall | OCI_18_1 | ORA-03136 | inbound connection timed out | — |
Definition at line 294 of file Connection.hpp.
References ocilib::core::Check(), and OCI_SetTimeout().