#include <AutoDatabaseConnection.h>
Public Member Functions | |
AutoDatabaseConnection (DatabaseConnectionPool &connectionPool) | |
AutoDatabaseConnection (const AutoDatabaseConnection &)=delete | |
AutoDatabaseConnection (AutoDatabaseConnection &&)=default | |
~AutoDatabaseConnection () | |
AutoDatabaseConnection & | operator= (const AutoDatabaseConnection &)=delete |
AutoDatabaseConnection & | operator= (AutoDatabaseConnection &&)=delete |
PoolDatabaseConnection * | connection () |
void | open (const String &connectionString="") const |
void | close () const |
bool | active () const |
const DatabaseConnectionString & | connectionString () const |
DatabaseConnectionType | connectionType () const |
String | driverDescription () const |
void | beginTransaction () const |
void | commitTransaction () const |
void | rollbackTransaction () const |
int | inTransaction () const |
void | objectList (DatabaseObjectType objectType, Strings &objects) const |
void | bulkInsert (const String &tableName, const Strings &columnNames, const std::vector< VariantVector > &data) const |
void | executeBatchFile (const String &batchFileName, Strings *errors=nullptr) const |
void | executeBatchSQL (const sptk::Strings &batchSQL, Strings *errors=nullptr) const |
Wrapper for CDatabase connection that automatically handles connection create and release
|
explicit |
Constructor Automatically gets connection from connection pool
connectionPool | Database connection pool |
sptk::AutoDatabaseConnection::~AutoDatabaseConnection | ( | ) |
Destructor Releases connection to connection pool
|
inline |
Returns true if database is opened
|
inline |
Begins the transaction
|
inline |
Executes bulk inserts of data from memory buffer
Data is inserted the fastest possible way. The server-specific format definition provides extra information about data. If format is empty than default server-specific data format is used. For instance, for PostgreSQL it is TAB-delimited data, with some escaped characters ('\t', '\n', '\r') and "\\N" for NULLs.
tableName | Table name to insert into |
columnNames | List of table columns to populate |
data | Data for bulk insert |
|
inline |
Closes the database connection. If unsuccessful throws an exception.
|
inline |
Commits the transaction
PoolDatabaseConnection * sptk::AutoDatabaseConnection::connection | ( | ) |
Returns database connection acquired from the connection pool
|
inline |
Returns the connection string
Referenced by open().
|
inline |
Returns the connection type
|
inline |
Returns the driver description
|
inline |
Executes SQL batch file
Queries are executed in not prepared mode. Syntax of the SQL batch file is matching the native for the database.
batchFileName | SQL batch file |
errors | Errors during execution. If provided, then errors are stored here, instead of exceptions |
|
inline |
Executes SQL batch queries
Queries are executed in not prepared mode. Syntax of the SQL batch file is matching the native for the database.
batchSQL | SQL batch file |
errors | Errors during execution. If provided, then errors are stored here, instead of exceptions |
|
inline |
Reports true if in transaction
|
inline |
Lists database objects
Not implemented in DatabaseConnection. The derived database class must provide its own implementation
objectType | Object type to list |
objects | Object list (output) |
|
inline |
Opens the database connection
If unsuccessful throws an exception.
connectionString | The ODBC connection string |
References connectionString().
|
inline |
Rolls back the transaction