*****************************/
-static const char *RCSID = "$Id: database.cpp,v 1.13 2011-03-24 10:21:47 arjen Exp $";
-
#include <date.h>
//#define DEBUG
** VARS CHANGED :
** FUNCTIONS USED :
** SEE ALSO :
-** LAST MODIFIED : Aug 17, 2003
+** LAST MODIFIED : Sep 23, 2020
**=========================================================================
*/
gnucomo_database::gnucomo_database(gnucomo_config *c)
{
+ dbconn = 0;
+ dbxact = 0;
cfg = c;
- dbconn = new pqxx::connection(cfg->Database());
-
- if (!dbconn->is_open())
+ try
{
- std::cerr << "Connection to database failed.\n";
- }
- else
- {
- try
+ dbconn = new pqxx::connection(cfg->Database());
+
+ if (!dbconn->is_open())
+ {
+ std::cerr << "Connection to database failed.\n";
+ }
+ else
{
// Create the transaction object
//dbxact = new pqxx::transaction<pqxx::serializable>(*dbconn, "GnuCoMo");
dbxact = new pqxx::work(*dbconn, "GnuCoMo");
+ gdb_refcount++;
}
- catch (std::exception &e)
- {
- *Log << "Cannot setup the database transaction: " << e.what() << "\n";
- *Log << "You are probably using incompatible versions of PostgreSQL an libpqxx.\n";
- exit(1);
- }
- gdb_refcount++;
+ }
+ catch (std::exception &e)
+ {
+ *Log << "Cannot setup the database transaction: " << e.what() << "\n";
}
}