***********************
** FILE NAME : database.cpp
** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
-** VERSION NUMBER : $Revision: 1.10 $
+** VERSION NUMBER : $Revision: 1.13 $
**
** DESCRIPTION : Implementation of the gnucomo database classes
**
/*****************************
$Log: database.cpp,v $
- Revision 1.10 2003-12-03 08:23:17 arjen
+ Revision 1.13 2011-03-24 10:21:47 arjen
+ Adjusted to new version of libpqxx.
+
+ Revision 1.12 2003/12/22 10:28:26 arjen
+ Catch an exception if we can not setup a database transaction.
+
+ Revision 1.11 2003/12/04 10:40:28 arjen
+ Fixed name conflict with 'double log(double)'
+
+ Revision 1.10 2003/12/03 08:23:17 arjen
Write messages to the log stream instead of cout.
Revision 1.9 2003/08/17 11:39:56 arjen
*****************************/
-static const char *RCSID = "$Id: database.cpp,v 1.10 2003-12-03 08:23:17 arjen Exp $";
+static const char *RCSID = "$Id: database.cpp,v 1.13 2011-03-24 10:21:47 arjen Exp $";
+
+#include <date.h>
-#include <AXE/date.h>
+//#define DEBUG
#include "database.h"
-extern std::ostream *log;
+extern std::ostream *Log;
/*=========================================================================
** NAME : gnucomo_database
{
cfg = c;
- dbconn = new pqxx::Connection(cfg->Database());
+ dbconn = new pqxx::connection(cfg->Database());
if (!dbconn->is_open())
{
}
else
{
- // Create the transaction object
+ try
+ {
+ // Create the transaction object
- dbxact = new pqxx::Transaction(*dbconn, "GnuCoMo");
+ //dbxact = new pqxx::transaction<pqxx::serializable>(*dbconn, "GnuCoMo");
+ dbxact = new pqxx::work(*dbconn, "GnuCoMo");
+ }
+ 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++;
}
}
{
if (--gdb_refcount == 0 && dbconn != 0 && dbxact != 0)
{
- dbxact->Commit();
+ dbxact->commit();
delete dbxact;
dbxact = 0;
delete dbconn;
String issueid("");
- *log << "Creating notification for " << issue << ": " << remark << "\n";
+ *Log << "Creating notification for " << issue << ": " << remark << "\n";
qry = "select type_of_issueid, suggested_priority from type_of_issue where name='";
qry += issue + "'";