libodbc++  0.2.5
Public Types | Public Member Functions | List of all members
odbc::Connection Class Reference

A database connection. More...

#include <connection.h>

Inheritance diagram for odbc::Connection:
odbc::ErrorHandler

Public Types

enum  TransactionIsolation {
  TRANSACTION_NONE, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ,
  TRANSACTION_SERIALIZABLE
}
 Transaction isolation constants. More...
 

Public Member Functions

virtual ~Connection ()
 Destructor. More...
 
bool getAutoCommit ()
 Returns true if autocommit is on.
 
void setAutoCommit (bool autoCommit)
 Sets the autocommit state of this connection. More...
 
void commit ()
 Commits the ongoing transaction.
 
void rollback ()
 Rollbacks the ongoing transaction.
 
std::string getCatalog ()
 Returns the current catalog.
 
void setCatalog (const std::string &catalog)
 Sets the current catalog.
 
TransactionIsolation getTransactionIsolation ()
 Returns the current transaction isolation level.
 
void setTransactionIsolation (TransactionIsolation isolation)
 Sets the current transaction isolation level.
 
bool isReadOnly ()
 Returns true if the connection is read only.
 
void setReadOnly (bool readOnly)
 Sets the read-only state of this connection.
 
bool getTrace ()
 Returns true if ODBC tracing is enabled on this connection.
 
void setTrace (bool on)
 Sets ODBC tracing on or off.
 
std::string getTraceFile ()
 Returns the file ODBC tracing is currently written to.
 
void setTraceFile (const std::string &s)
 Sets the file ODBC tracing is written to.
 
DatabaseMetaDatagetMetaData ()
 Returns meta information for this connection. More...
 
StatementcreateStatement ()
 Creates a non-prepared statement. More...
 
StatementcreateStatement (int resultSetType, int resultSetConcurrency)
 Creates a non-prepared statement. More...
 
PreparedStatementprepareStatement (const std::string &sql)
 Create a prepared statement. More...
 
PreparedStatementprepareStatement (const std::string &sql, int resultSetType, int resultSetConcurrency)
 Create a prepared statement. More...
 
CallableStatementprepareCall (const std::string &sql)
 Create a callable prepared statement. More...
 
CallableStatementprepareCall (const std::string &sql, int resultSetType, int resultSetConcurrency)
 Create a callable prepared statement. More...
 
std::string nativeSQL (const std::string &sql)
 Translate a given SQL string into this data sources' own SQL grammar.
 
- Public Member Functions inherited from odbc::ErrorHandler
void clearWarnings ()
 Clears all the warnings stored in this object.
 
WarningList * getWarnings ()
 Fetches all the warnings in this object. More...
 
virtual ~ErrorHandler ()
 Destructor.
 

Additional Inherited Members

- Protected Member Functions inherited from odbc::ErrorHandler
 ErrorHandler (bool collectWarnings=true)
 Constructor.
 

Detailed Description

A database connection.

Member Enumeration Documentation

Transaction isolation constants.

Enumerator
TRANSACTION_NONE 

The data source does not support transactions.

TRANSACTION_READ_UNCOMMITTED 

Dirty reads, non-repeatable reads and phantom reads can occur.

TRANSACTION_READ_COMMITTED 

Non-repeatable and phantom reads can occur.

TRANSACTION_REPEATABLE_READ 

Phantom reads can occur.

TRANSACTION_SERIALIZABLE 

Simply no problems.

Constructor & Destructor Documentation

virtual odbc::Connection::~Connection ( )
virtual

Destructor.

Closes the connection

Member Function Documentation

Statement* odbc::Connection::createStatement ( )

Creates a non-prepared statement.

Example: std::auto_ptr<Statement> stmt(cnt->createStatement());

Statement* odbc::Connection::createStatement ( int  resultSetType,
int  resultSetConcurrency 
)

Creates a non-prepared statement.

Example: std::auto_ptr<Statement> stmt(cnt->createStatement(x, y));

Parameters
resultSetTypeThe type for ResultSets created by this statement
resultSetConcurrencyThe concurrency for ResultSets created by this statement
DatabaseMetaData* odbc::Connection::getMetaData ( )

Returns meta information for this connection.

Note that the returned object is 'owned' by this connection and should in no way be deleted by the caller.

Example: DatabaseMetaData* dmd = cnt->getMetaData();

CallableStatement* odbc::Connection::prepareCall ( const std::string &  sql)

Create a callable prepared statement.

Example: std::auto_ptr<CallableStatement> cstmt(cnt->prepareCall(s));

Parameters
sqlThe string to prepare, optionally containing parameter markers for input and/or output parameters
CallableStatement* odbc::Connection::prepareCall ( const std::string &  sql,
int  resultSetType,
int  resultSetConcurrency 
)

Create a callable prepared statement.

Example: std::auto_ptr<CallableStatement> cstmt(cnt->prepareCall(s, x, y));

Parameters
sqlThe string to prepare, optionally containing parameter markers for input and/or output parameters
resultSetTypeThe type for ResultSets created by this statement
resultSetConcurrencyThe concurrency for ResultSets created by this statement
PreparedStatement* odbc::Connection::prepareStatement ( const std::string &  sql)

Create a prepared statement.

Example: std::auto_ptr<PreparedStatement> pstmt(cnt->prepareStatement(s));

Parameters
sqlThe string to prepare, optionally containing parameter markers (?).
PreparedStatement* odbc::Connection::prepareStatement ( const std::string &  sql,
int  resultSetType,
int  resultSetConcurrency 
)

Create a prepared statement.

Example: std::auto_ptr<PreparedStatement> pstmt(cnt->prepareStatement(s, x, y));

Parameters
sqlThe string to prepare, optionally containing parameter markers.
resultSetTypeThe type for ResultSets created by this statement
resultSetConcurrencyThe concurrency for ResultSets created by this statement
void odbc::Connection::setAutoCommit ( bool  autoCommit)

Sets the autocommit state of this connection.

Parameters
autoCommittrue for on, false for off

The documentation for this class was generated from the following file:

Go back to the libodbc++ homepage