67 StatusCode status = Service::initialize();
68 if ( !status.isSuccess() )
return status;
70 MsgStream log(
msgSvc(), name() );
72 m_serviceInuse = name();
75 bool use_sqlite =
false;
76 bool use_mysql =
false;
78 std::transform( m_dbType.begin(), m_dbType.end(), m_dbType.begin(), ::toupper );
80 if ( m_dbType ==
"MYSQL" ) use_mysql =
true;
82 if ( m_dbType ==
"SQLITE" ) use_sqlite =
true;
84 log << MSG::DEBUG <<
"Using " << m_dbType <<
" interface with options:" << endmsg;
90 log << MSG::DEBUG <<
" dbHost " << m_dbHost << endmsg;
91 log << MSG::DEBUG <<
" dbPort " << m_dbPort << endmsg;
92 log << MSG::DEBUG <<
" dbUser " << m_dbUser << endmsg;
93 log << MSG::DEBUG <<
" dbPasswd " << m_dbPasswd << endmsg;
96 dbInterface->set_host( m_dbHost );
97 dbInterface->set_port( m_dbPort );
98 dbInterface->set_user( m_dbUser );
99 dbInterface->set_passwd( m_dbPasswd );
101 else if ( use_sqlite )
103 log << MSG::DEBUG <<
" dbFilepath " << m_dbFilePath << endmsg;
106 dbInterface->set_dbpath( m_dbFilePath );
111 <<
"No valid database type is set. Please choose either MYSQL or SQLITE " << endmsg;
112 return StatusCode::FAILURE;
115 if ( m_dbReuseConnection ) log << MSG::DEBUG <<
"One connection per job is used" << endmsg;
116 else log << MSG::DEBUG <<
"One connection per query is used" << endmsg;
118 if ( m_dbReuseConnection )
120 dbInterface->set_reuse_connection(
true );
121 dbInterface->connect();
123 }
catch ( std::exception& e )
126 log << MSG::FATAL <<
"Exception in DataSvc initialization:" << endmsg;
127 log << MSG::FATAL <<
"*** error message: " << e.what() << endmsg;
128 return StatusCode::FAILURE;
129 }
catch (
char* mess )
131 log << MSG::FATAL <<
"Exception DataSvc initialization caught: " << mess << endmsg;
132 return StatusCode::FAILURE;
135 log << MSG::FATAL <<
"UNKNOWN exception in DataSvc session initialization caught"
137 return StatusCode::FAILURE;
140 log << MSG::INFO <<
"DatabaseSvc initialized successfully" << endmsg;
141 return StatusCode::SUCCESS;