69{
70 StatusCode status = Service::initialize();
71 if ( !status.isSuccess() ) return status;
72
73 MsgStream log(
msgSvc(), name() );
75 setProperties();
76
77 bool use_sqlite = false;
78 bool use_mysql = false;
79
80 std::transform(m_dbType.begin(), m_dbType.end(), m_dbType.begin(), ::toupper);
81
82 if(m_dbType=="MYSQL")
83 use_mysql = true;
84
85 if(m_dbType=="SQLITE")
86 use_sqlite = true;
87
88 log << MSG::DEBUG << "Using " << m_dbType
89 << " interface with options:" << endreq;
90
91 try {
92 if(use_mysql)
93 {
94 log << MSG::DEBUG << " dbHost " << m_dbHost << endreq;
95 log << MSG::DEBUG << " dbPort " << m_dbPort << endreq;
96 log << MSG::DEBUG << " dbUser " << m_dbUser << endreq;
97 log << MSG::DEBUG << " dbPasswd " << m_dbPasswd << endreq;
98
104 }
105 else if(use_sqlite)
106 {
107 log << MSG::DEBUG << " dbFilepath " << m_dbFilePath << endreq;
108
111 }
112 else
113 {
114 log << MSG::FATAL << "No valid database type is set. Please choose either MYSQL or SQLITE " << endreq;
115 return StatusCode::FAILURE;
116 }
117
118 if(m_dbReuseConnection)
119 log << MSG::DEBUG << "One connection per job is used" << endreq;
120 else
121 log << MSG::DEBUG << "One connection per query is used" << endreq;
122
123 if( m_dbReuseConnection )
124 {
127 }
128
129 } catch ( std::exception &e ) {
130
131 log << MSG::FATAL << "Exception in DataSvc initialization:" << endreq;
132 log << MSG::FATAL << "*** error message: " << e.what() << endreq;
133 return StatusCode::FAILURE;
134
135 } catch (char* mess) {
136 log << MSG::FATAL << "Exception DataSvc initialization caught: " << mess << endreq;
137 return StatusCode::FAILURE;
138 }
139 catch (...) {
140 log << MSG::FATAL << "UNKNOWN exception in DataSvc session initialization caught" << endreq;
141 return StatusCode::FAILURE;
142 }
143
144 log << MSG::INFO << "DatabaseSvc initialized successfully" << endreq;
145 return StatusCode::SUCCESS;
146}
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)