Represents a database API. The point you have to start with. More...

Inherits SAOptions.

Public Member Functions

 SAPI (bool unloadAPI=false)
 Default constructor.
 
 SAPI (SAClient_t eSAClient, bool unloadAPI=false) SQLAPI_THROW(SAException)
 Initializes the object with specific DBMS API type.
 
virtual ~SAPI ()
 A destructor. More...
 
void setClient (SAClient_t eSAClient) SQLAPI_THROW(SAException)
 Assigns an DBMS client for the API class. More...
 
SAClient_t Client () const
 Returns the current DBMS client assigned for the connection.
 
int ClientVersion () const SQLAPI_THROW(SAException)
 Returns the DBMS client API version number. More...
 
IsaAPINativeAPI () const SQLAPI_THROW(SAException)
 Returns a native DBMS client API object. More...
 
bool isUnloadAPI () const
 Returns native API unload flag value.
 
void setAutoUnInitialize (bool bVal)
 Set native API auto-uninitialize flag value. More...
 
void ThreadInit () SQLAPI_THROW(SAException)
 Initializes DBMS thread-specific resources. More...
 
void ThreadEnd () SQLAPI_THROW(SAException)
 Frees DBMS already allocated thread-specific resources. More...
 
- Public Member Functions inherited from SAOptions
 SAOptions ()
 Default constructor.
 
virtual SAStringsetOption (const SAString &sOptionName)
 Sets a string value of a specific option. More...
 
virtual SAString Option (const SAString &sOptionName) const
 Returns a string value of a specific option.
 
virtual int TotalOptions () const
 Returns the count of options.
 
virtual SAString OptionName (int nIndex) const
 Returns the string value of an option.
 

Detailed Description

Represents a database API. The point you have to start with.

The SAPI class represents a database API. You may need to have a DBMS API initialized before you can operate on the database - furthermore the SAConnection needs to be connected. It is important to note that DBMS API objects are not initialized during construction - it is up to the user to explicitly call SAPI::setClient method for the object after it is created and before it is used. DBMS API connection object is normally shared by the other objects those require a DBMS aceccing (e.g. SAConnection object).

Constructor & Destructor Documentation

◆ ~SAPI()

SAPI::~SAPI ( )
virtual

A destructor.

Implicitly closes and deassosiates all linked SAConnection.

Uninitializes DBMS API library.

Member Function Documentation

◆ setClient()

void SAPI::setClient ( SAClient_t  eSAClient)

Assigns an DBMS client for the API class.

Parameters
eSAClientOne of the following values from SAClient_t enum.
Exceptions
SAException
Remarks
You can set a client in constructor, in this case you don't need to use setClient method. The main destination of this method is to initialize DBMS API (for example, to check a client availability and version).
If you are calling setClient method when the related connection is set to another client the previous connection will be disconnected and new client will be set.

◆ ClientVersion()

int SAPI::ClientVersion ( ) const

Returns the DBMS client API version number.

Returns
The int number of a client API version.
Exceptions
SAException
Remarks
The higher word contains the major client version (the XX value in the XX.YY version number); the lower word contains the minor client version (the YY value in the XX.YY version number).
If an DBMS client was not set calling ClientVersion method will throw an exception.

◆ NativeAPI()

IsaAPI * SAPI::NativeAPI ( ) const

Returns a native DBMS client API object.

Returns
A pointer to a base class ISAPI from which a family of DBMS implementation-specific classes are derived.
Remarks
Use this method if you want to call client specific API functions which are not directly supported by the Library. The method returns a pointer to the set of native API functions available for an DBMS client you currently use. To use the database API directly you have to downcast this ISAPI pointer to the appropriate type and use its implementation-specific members.

See Server Specific Guides section to know what type cast you have to make and what additional header file you have to include to work with specific DBMS client API. Note that for some DBMS using appropriate type casting depends on an API version (that generally mean that you have to explicitly check client version before casting, see SAPI::ClientVersion method).
To get more information about DBMS API functions see this DBMS specific documentation.
Please be aware of the complications associated with making direct API calls, as the internal logic of the SQLAPI++ Library is not used. Besides, making direct API calls reduces an application's portability.

◆ setAutoUnInitialize()

void SAPI::setAutoUnInitialize ( bool  bVal)

Set native API auto-uninitialize flag value.

When this flag is set DBMS API is uninitialized just the latest linked SAConnection unregistered.

◆ ThreadInit()

void SAPI::ThreadInit ( )

Initializes DBMS thread-specific resources.

Exceptions
SAException
Remarks
This method must be called within each application thread to initialize thread-specific resources.

This method prepares DBMS API for using with an application thread if it's needed. For MySQL, MariaDB it calls mysql_thread_init function. For SQL Server(OLEDB) it initializes OLE/COM subsystem.

See also
SAPI::ThreadEnd

◆ ThreadEnd()

void SAPI::ThreadEnd ( )

Frees DBMS already allocated thread-specific resources.

Exceptions
SAException
Remarks
Call this function as necessary before an application thread exits to free memory allocated by SAPI::ThreadInit.
See also
SAPI::ThreadInit