16 m_writeStmt =
nullptr;
31 this->checkConnection();
33 m_readStmt = m_conn->createStatement();
34 m_readStmt->setSQL(
"select FE_CONFIG_COKE_SQ.NextVal from DUAL ");
35 ResultSet* rset = m_readStmt->executeQuery();
36 while (rset->next()) {
40 m_conn->terminateStatement(m_readStmt);
44 throw(std::runtime_error(
std::string(
"FEConfigCokeInfo::fetchNextId(): ") +
e.getMessage()));
49 this->checkConnection();
53 next_id = fetchNextId();
57 m_writeStmt = m_conn->createStatement();
58 m_writeStmt->setSQL(
"INSERT INTO " + getTable() +
59 " ( coke_conf_id, tag, version) "
60 " VALUES ( :1, :2, :3 ) ");
62 m_writeStmt->setInt(1, next_id);
66 throw(std::runtime_error(
std::string(
"FEConfigCokeInfo::prepareWrite(): ") +
e.getMessage()));
74 for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
75 if (ci->first ==
"VERSION")
76 setVersion(atoi(ci->second.c_str()));
77 if (ci->first ==
"TAG")
78 setConfigTag(ci->second);
83 this->checkConnection();
88 m_writeStmt->setString(2, this->getConfigTag());
89 m_writeStmt->setInt(3, this->getVersion());
91 m_writeStmt->executeUpdate();
94 throw(std::runtime_error(
std::string(
"FEConfigCokeInfo::writeDB(): ") +
e.getMessage()));
97 if (!this->fetchID()) {
98 throw(std::runtime_error(
"FEConfigCokeInfo::writeDB: Failed to write"));
103 this->checkConnection();
105 if (
result->getId() == 0 && (
result->getConfigTag().empty())) {
106 throw(std::runtime_error(
"FEConfigCokeInfo::fetchData(): no Id defined for this FEConfigCokeInfo "));
112 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where ( coke_conf_id= :1 or (tag=:2 AND version=:3 ) )");
113 m_readStmt->setInt(1,
result->getId());
114 m_readStmt->setString(2,
result->getConfigTag());
115 m_readStmt->setInt(3,
result->getVersion());
116 ResultSet* rset = m_readStmt->executeQuery();
122 result->setId(rset->getInt(1));
123 result->setConfigTag(rset->getString(2));
124 result->setVersion(rset->getInt(3));
126 Date dbdate = rset->getDate(4);
127 result->setDBTime(
dh.dateToTm(dbdate));
130 throw(std::runtime_error(
std::string(
"FEConfigCokeInfo::fetchData(): ") +
e.getMessage()));
135 this->checkConnection();
140 m_readStmt->setSQL(
"SELECT * FROM " + getTable() +
" where coke_conf_id = ( select max( coke_conf_id) from " +
142 ResultSet* rset = m_readStmt->executeQuery();
146 result->setId(rset->getInt(1));
147 result->setConfigTag(rset->getString(2));
148 result->setVersion(rset->getInt(3));
149 Date dbdate = rset->getDate(4);
150 result->setDBTime(
dh.dateToTm(dbdate));
153 throw(std::runtime_error(
std::string(
"FEConfigCokeInfo::fetchData(): ") +
e.getMessage()));
163 this->checkConnection();
166 Statement* stmt = m_conn->createStatement();
167 stmt->setSQL(
"SELECT coke_conf_id FROM " + getTable() +
" WHERE tag=:1 and version=:2 ");
169 stmt->setString(1, getConfigTag());
170 stmt->setInt(2, getVersion());
172 ResultSet* rset = stmt->executeQuery();
175 m_ID = rset->getInt(1);
179 m_conn->terminateStatement(stmt);
181 throw(std::runtime_error(
std::string(
"FEConfigCokeInfo::fetchID: ") +
e.getMessage()));
188 this->checkConnection();
193 Statement* stmt = m_conn->createStatement();
195 stmt->setSQL(
"SELECT * FROM " + getTable() +
" WHERE coke_conf_id = :1");
198 ResultSet* rset = stmt->executeQuery();
200 this->setId(rset->getInt(1));
201 this->setConfigTag(rset->getString(2));
202 this->setVersion(rset->getInt(3));
204 Date dbdate = rset->getDate(4);
205 this->setDBTime(
dh.dateToTm(dbdate));
207 throw(std::runtime_error(
"FEConfigCokeInfo::setByID: Given config_id is not in the database"));
210 m_conn->terminateStatement(stmt);
212 throw(std::runtime_error(
std::string(
"FEConfigCokeInfo::setByID: ") +
e.getMessage()));