67{
68 StatusCode status = Service::initialize();
69 if ( !status.isSuccess() ) return status;
70
71 MsgStream log(
msgSvc(), name() );
73 setProperties();
74
75 bool use_sqlite = false;
76 bool use_mysql = false;
77
78 std::transform(m_dbType.begin(), m_dbType.end(), m_dbType.begin(), ::toupper);
79
80 if(m_dbType=="MYSQL")
81 use_mysql = true;
82
83 if(m_dbType=="SQLITE")
84 use_sqlite = true;
85
86 log << MSG::DEBUG << "Using " << m_dbType
87 << " interface with options:" << endreq;
88
89 try {
90 if(use_mysql)
91 {
92 log << MSG::DEBUG << " dbHost " << m_dbHost << endreq;
93 log << MSG::DEBUG << " dbUser " << m_dbUser << endreq;
94 log << MSG::DEBUG << " dbPasswd " << m_dbPasswd << endreq;
95
100 }
101 else if(use_sqlite)
102 {
103 log << MSG::DEBUG << " dbFilepath " << m_dbFilePath << endreq;
104
107 }
108 else
109 {
110 log << MSG::FATAL << "No valid database type is set. Please choose either MYSQL or SQLITE " << endreq;
111 return StatusCode::FAILURE;
112 }
113
114 if(m_dbReuseConnection)
115 log << MSG::DEBUG << "One connection per job is used" << endreq;
116 else
117 log << MSG::DEBUG << "One connection per query is used" << endreq;
118
119 if( m_dbReuseConnection )
120 {
123 }
124
125 } catch ( std::exception &e ) {
126
127 log << MSG::FATAL << "Exception in DataSvc initialization:" << endreq;
128 log << MSG::FATAL << "*** error message: " << e.what() << endreq;
129 return StatusCode::FAILURE;
130
131 } catch (char* mess) {
132 log << MSG::FATAL << "Exception DataSvc initialization caught: " << mess << endreq;
133 return StatusCode::FAILURE;
134 }
135 catch (...) {
136 log << MSG::FATAL << "UNKNOWN exception in DataSvc session initialization caught" << endreq;
137 return StatusCode::FAILURE;
138 }
139
140 log << MSG::INFO << "DatabaseSvc initialized successfully" << endreq;
141 return StatusCode::SUCCESS;
142}
void set_dbpath(std::string path)
void set_host(std::string host)
void set_passwd(std::string passwd)
void set_reuse_connection(bool flag)
void set_user(std::string user)