ODBC database connection. More...
#include <connection.h>
Public Types | |
| enum | transaction_isolation { READ_UNCOMMITTED, READ_COMMITTED, REPEATABLE_READ, SERIALIZABLE } |
Transaction isolation level. | |
Public Member Functions | |
| connection () | |
| Constructor. | |
| virtual | ~connection () |
| Destructor. | |
| void | open (const std::string &dsn, const std::string &user_name, const std::string &password) |
| Connect to database. | |
| void | open (const std::string &connect_string) |
| Connect to database. | |
| bool | is_open () const |
| Check the connection state. | |
| void | close () |
| Disconnect from database. | |
| void | begin_transaction (transaction_isolation level=READ_COMMITTED) |
| Start the transaction. | |
| void | commit () |
| Commit the transaction. | |
| void | rollback () |
| Roll back the transaction. | |
Protected Member Functions | |
| std::string | get_error () const |
Friends | |
| class | query |
ODBC database connection.
This class represents the database connection via ODBC.
| void dbp::odbc::connection::begin_transaction | ( | transaction_isolation | level = READ_COMMITTED |
) |
Start the transaction.
Turns off default autocommit mode and starts the transaction. Use commit or rollback methods to save or cancel changes.
| level | the transaction isolation level |
| void dbp::odbc::connection::close | ( | ) |
Disconnect from database.
Closes the connection to the database.
| void dbp::odbc::connection::commit | ( | ) |
Commit the transaction.
Save changes since last begin_transaction call. After commiting the transaction the autocommit mode is turning on.
| bool dbp::odbc::connection::is_open | ( | ) | const |
Check the connection state.
Returns true if the connection is opened and false otherwise.
| void dbp::odbc::connection::open | ( | const std::string & | connect_string | ) |
Connect to database.
Opens the connection to the database.
| connect_string | the full ODBC connection string. |
| void dbp::odbc::connection::open | ( | const std::string & | dsn, | |
| const std::string & | user_name, | |||
| const std::string & | password | |||
| ) |
Connect to database.
Opens the connection to the database.
| dsn | the ODBC connection name. | |
| user_name | the user login. | |
| password | the user password. |
| void dbp::odbc::connection::rollback | ( | ) |
Roll back the transaction.
Cancel changes since last begin_transaction call. After rolling back the transaction the autocommit mode is turning on.