IDatabaseConnection Class
(CDP2SQL::IDatabaseConnection)Abstract interface that all CDP2SQL database drivers must implement. More...
| Header: | #include <IDatabaseConnection> |
Public Functions
| virtual | ~IDatabaseConnection() |
| virtual void | Close() = 0 |
| virtual int | Connect(const std::string &database = {}, void *connectionInfo = 0) = 0 |
| virtual IDatabaseQuery * | CreateQuery() = 0 |
| virtual IDatabaseStatement * | CreateStatement() = 0 |
| virtual void | DestroyQuery(IDatabaseQuery *pQuery) = 0 |
| virtual void | DestroyStatement(IDatabaseStatement *pStatement) = 0 |
| virtual void | Execute(const std::string &sqlString) = 0 |
| virtual int | ExecuteScalar(const std::string &sqlString) = 0 |
| virtual std::string | GetDBType() const = 0 |
| virtual void | InterruptSql() = 0 |
| virtual bool | TableExists(const std::string &tableName) = 0 |
| virtual bool | TestConnection() = 0 |
| virtual void | WalCheckpoint() = 0 |
Detailed Description
Abstract interface that all CDP2SQL database drivers must implement.
This interface should not be used directly but passed into CDP2SQL::Database class.
Member Function Documentation
[virtual] IDatabaseConnection::~IDatabaseConnection()
Should have virtual destructor for all abstract classes. Must close connection if open.
[pure virtual] void IDatabaseConnection::Close()
Closes the database connection.
[pure virtual] int IDatabaseConnection::Connect(const std::string &database = {}, void *connectionInfo = 0)
Connecting to the database:
Parameters:
- database - Database to open after connecting (optional).
- connectionInfo - Pointer to very database-specific configuration setup. Normally not needed.
Throws CDP2SQL::SQLException if unsupported parameters or unexpected errors occur.
Returns a positive value on success, which may include database-specific information.
[pure virtual] IDatabaseQuery *IDatabaseConnection::CreateQuery()
Creates a database-specific Query object.
Do not delete the returned object, instead pass it to DestroyQuery()
[pure virtual] IDatabaseStatement *IDatabaseConnection::CreateStatement()
Creates a database-specific Statement object.
Do not delete the returned object, instead pass it to DestroyStatement()
[pure virtual] void IDatabaseConnection::DestroyQuery(IDatabaseQuery *pQuery)
Destroy a database-specific Query object returned by this class.
[pure virtual] void IDatabaseConnection::DestroyStatement(IDatabaseStatement *pStatement)
Destroy a database-specific Statement object returned by this class.
[pure virtual] void IDatabaseConnection::Execute(const std::string &sqlString)
Executes a SQL data manipulation command.
Example:
db.Execute( "insert into mytable values (1, "foobar);" );
[pure virtual] int IDatabaseConnection::ExecuteScalar(const std::string &sqlString)
Executes a simple SQL query that returns a single scalar value.
Example:
db.ExecuteScalar( "select count(*) from mytable;" );
Returns the single integer result from the query.
[pure virtual] std::string IDatabaseConnection::GetDBType() const
Database type as a string (e.g. "sqlite3" or "mysql")
[pure virtual] void IDatabaseConnection::InterruptSql()
Asks any pending database operation to abort and return at its earliest opportunity.
It is safe to call this routine from a thread different from the thread that is currently running the database operation.
[pure virtual] bool IDatabaseConnection::TableExists(const std::string &tableName)
Returns true if the database has a table with this name.
[pure virtual] bool IDatabaseConnection::TestConnection()
Pings the database to check if the connection is still up. Returns whether the Database is connected.
[pure virtual] void IDatabaseConnection::WalCheckpoint()
Causes checkpoint/sync on databases that supports Write-Ahead Logging.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.