diff --git a/SAS/Feedback_Service/src/Feedback.cc b/SAS/Feedback_Service/src/Feedback.cc index ece6062217f27ba5d688ef700621141cf007d3af..76ec99cca9e26a0d32d6e07c1b8eaedeb96ee0f6 100644 --- a/SAS/Feedback_Service/src/Feedback.cc +++ b/SAS/Feedback_Service/src/Feedback.cc @@ -128,15 +128,74 @@ GCFEvent::TResult Feedback::connect2OTDB_state(GCFEvent& event, GCFPortInterface LOG_DEBUG_STR("Trying to read database information from file " << filename); ParameterSet otdbconf; otdbconf.adoptFile(filename); - string database = otdbconf.getString("SASGateway.OTDBdatabase"); - string dbhost = otdbconf.getString("SASGateway.OTDBhostname"); - itsOTDBconn = new OTDBconnection("paulus", "boskabouter", database, dbhost); + string database; + try + { + database = otdbconf.getString("SASGateway.OTDBdatabase"); + } + catch(LOFAR::APSException& ex) + { + LOG_ERROR_STR("FeedbackService code caught an exception while trying to " + "read the OTDB database name from its configuration file: " + << ex.what()); + throw(ex); + } + string dbhost; + try + { + dbhost = otdbconf.getString("SASGateway.OTDBhostname"); + } + catch(LOFAR::APSException& ex) + { + LOG_ERROR_STR("FeedbackService code caught an exception while trying to " + "read the OTDB database server host name from its configuration file: " + << ex.what()); + throw(ex); + } + string username; + try + { + username = otdbconf.getString("SASGateway.OTDBusername"); + } + catch(LOFAR::APSException& ex) + { + LOG_ERROR_STR("FeedbackService code caught an exception while trying to " + "read the OTDB database user name from its configuration file: " + << ex.what()); + throw(ex); + } + string password; + try + { + password = otdbconf.getString("SASGateway.OTDBpassword"); + } + catch(LOFAR::APSException& ex) + { + LOG_ERROR_STR("FeedbackService code caught an exception while trying to " + "read the OTDB database password from its configuration file: " + << ex.what()); + throw(ex); + } + string port; + try + { + port = otdbconf.getString("SASGateway.OTDBport"); + } + catch(LOFAR::APSException& ex) + { + LOG_ERROR_STR("FeedbackService code caught an exception while trying to " + "read the OTDB database server port from its configuration file: " + << ex.what()); + throw(ex); + } + + itsOTDBconn = new OTDBconnection(username, password, database, dbhost, port); if (!itsOTDBconn->connect()) { - LOG_FATAL_STR("Cannot connect to database " << database << " on machine " << dbhost << ", retry in 10 seconds"); + LOG_FATAL_STR("Cannot connect to database " << database << " on machine " << dbhost << " on port " << port << ", retry in 10 seconds"); itsTimer->setTimer(10.0); return (GCFEvent::HANDLED); } - LOG_INFO_STR("Connected to database " << database << " on machine " << dbhost); + LOG_INFO_STR("Connected to database " << database << " on machine " << dbhost << " on port " << port); TRAN(Feedback::operational_state); } break;