OSB_DB::Session Class Reference

Collaboration diagram for OSB_DB::Session:

Collaboration graph
[legend]
List of all members.

Detailed Description

Class Session provides thread-safe database connection and transaction control.

Each session controls one connection to an Oracle database. Multiple sessions can be active and connected to different databases at the same time.

Attention:
Every application using database sessions must declare an instance of SessionCtrl, see there for details.

Definition at line 63 of file dbsession.h.

Public Member Functions

Read access to connection settings
Connection and transaction control:
All these functions throw DbException in case of an SQL error.

Static Public Attributes

Private Member Functions

Private Attributes


Constructor & Destructor Documentation

OSB_DB::Session::Session (  ) 

Empty default constructor.

OSB_DB::Session::Session ( const std::string &  username,
const std::string &  password,
const std::string &  database 
)

Constructor with connection settings.

It does not logon to the database.

Parameters:
username Name of the database user.
password Password for the database user.
database TNS name of database instance.

OSB_DB::Session::Session ( const Session  ) 

Copy constructor.

It can be used only if the session is not connected.

Exceptions:
OsbException if the session is connected.

OSB_DB::Session::~Session (  ) 

Destructor.

Calls logoff() if the session is still connected.


Member Function Documentation

void OSB_DB::Session::alterSession ( std::string  clause  ) 

Specify or modify session specific options and settings. The session needs to be connected.

Use this command to execute any ALTER SESSION statement. Pass the statement in the clause string, the function will prepend "ALTER SESSION " and execute it.

Parameters:
clause The alter session command that is executed on the database (without ALTER SESSION).

void OSB_DB::Session::commit (  ) 

Commit a database transaction.

bool OSB_DB::Session::connected (  )  const

const std::string& OSB_DB::Session::database (  )  const

void OSB_DB::Session::logoff ( bool  msg = false  ) 

Logoff from the database.

Parameters:
msg Write logoff message to Log?
Note:
If the session is not connected the function returns immediately without effect.

void OSB_DB::Session::logon ( const std::string &  username,
const std::string &  password,
const std::string &  database,
bool  msg = false 
)

Logon to the database.

Parameters:
username Database user.
password Database password.
database Database name.
msg Write logon message to Log?
Exceptions:
OsbException if the session is connected.

void OSB_DB::Session::logon ( bool  msg = false  ) 

Logon to the database.

Uses the username, password and database supplied in the constructor to connect to the database.

Parameters:
msg Write logon message to Log?
Exceptions:
OsbException if the session is connected.

OSB_DB::Session::operator otl_connect & (  )  const

Convery to a non-const otl_connect.

Exceptions:
OsbException if the session is not connected.
This is needed to construct otl_nocommit_stream and (NOT USED IN OSB) otl_stream:
          void UnitGw::fetch(const Session& session)
          {
              otl_nocommit_stream dbSelect(
                FEW_ROWS,
                "SELECT unit_id, name "
                       "FROM UNIT "
                "ORDER BY unit_id",
                session);
          }

Session& OSB_DB::Session::operator= ( const Session rhs  )  [private]

Prevent assignment: not implemented.

const std::string& OSB_DB::Session::password (  )  const

void OSB_DB::Session::rollback (  ) 

Rollback a database transaction.

const std::string& OSB_DB::Session::username (  )  const


Member Data Documentation

std::string OSB_DB::Session::database_ [private]

DB to connect to.

Definition at line 205 of file dbsession.h.

const char* OSB_DB::Session::nlsDateFormat_ [static]

OSB default date format for database statements.

Attention:
There is code in other source files which depends on this format. E.g., if this format is changed, OSB_LIB::DateTime must be changed as well!

Definition at line 72 of file dbsession.h.

otl_connect* OSB_DB::Session::otlConnect_ [mutable, private]

The OTL database connection.

Definition at line 199 of file dbsession.h.

std::string OSB_DB::Session::password_ [private]

Password for DB connection.

Definition at line 203 of file dbsession.h.

std::string OSB_DB::Session::username_ [private]

Username for DB connection.

Definition at line 201 of file dbsession.h.


The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:08:57 2006 for OSB Library by  doxygen 1.4.7