10 #include <soci/sqlite3/soci-sqlite3.h>
19 DBSessionManager::DBSessionManager() : _dbSession (NULL) {
23 DBSessionManager::DBSessionManager (
const DBParams& iDBParams)
29 DBSessionManager::~DBSessionManager() {
30 delete _dbSession; _dbSession = NULL;
34 soci::session& DBSessionManager::getDBSessionRef()
const {
35 assert (_dbSession != NULL);
40 void DBSessionManager::init (
const DBParams& iDBParams) {
43 if (iDBParams.checkSQLite() ==
false) {
44 std::ostringstream errorStr;
45 errorStr <<
"At least one of the parameters for the SQL "
46 <<
"database is empty: " << iDBParams;
48 throw XapianTravelDatabaseEmptyException (errorStr.str());
53 _dbSession =
new soci::session();
58 _dbSession->open (soci::sqlite3, iDBParams.toSQLiteConnectionString());
60 }
catch (std::exception
const& lException) {
61 std::ostringstream errorStr;
62 errorStr <<
"Error while opening a connection to database: "
63 << lException.what() << std::endl;
64 errorStr <<
"Database parameters used: " << iDBParams.toString();
66 throw SQLDatabaseConnectionImpossibleException (errorStr.str());
#define OPENTREP_LOG_ERROR(iToBeLogged)