All,
I am trying to design a cache object (singleton) that gets the desired
object directly from the database if it is not already in the cache.
The db connection is a static class member:
Cache.h:
class Cache {
static log4cxx::LoggerPtr logger;
static pqxx::connection dbCon;
public:
...
}
The connection is going to be initialized in the source file Cache.cpp
before the class methods:
...
pqxx::connection
Cache::dbCon("user=postgres password=xxxx dbname=mydb
hostaddr=127.0.0.1 port=5432");
Cache::Cache() { ... }
...
The connection constructor could throw an exception. How do I catch that?
Java allows a static block to handle that, C++ AFAIK doesn't.
I was googleing it but could not find anything; neither in FAQ's. Its
probably trivial so please be nice to me. ;-)
Thanks for your help,
-- Bernd