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