13 m_writeStmt =
nullptr;
36 this->checkConnection();
38 m_readStmt = m_conn->createStatement();
39 m_readStmt->setSQL(
"select ecal_JBH4_config_sq.NextVal from dual");
40 ResultSet *rset = m_readStmt->executeQuery();
41 while (rset->next()) {
44 m_conn->terminateStatement(m_readStmt);
48 throw(std::runtime_error(
"ODJBH4Config::fetchNextId(): " +
e.getMessage()));
53 this->checkConnection();
54 int next_id = fetchNextId();
57 m_writeStmt = m_conn->createStatement();
59 "INSERT INTO ECAL_Jbh4_CONFIGURATION ( jbh4_configuration_id, jbh4_tag, "
60 " useBuffer, halModuleFile, halAddressTableFile, halStaticTableFile, halcbd8210serialnumber, "
61 " caenbridgetype, caenlinknumber, caenboardnumber) "
62 " VALUES ( :1, :2, :3, :4, :5, :6, :7, :8 , :9, :10 )");
64 m_writeStmt->setInt(1, next_id);
67 throw(std::runtime_error(
"ODJBH4Config::prepareWrite(): " +
e.getMessage()));
72 this->checkConnection();
77 m_writeStmt->setString(2, this->getConfigTag());
79 m_writeStmt->setInt(3, this->getUseBuffer());
80 m_writeStmt->setString(4, this->getHalModuleFile());
81 m_writeStmt->setString(5, this->getHalAddressTableFile());
82 m_writeStmt->setString(6, this->getHalStaticTableFile());
83 m_writeStmt->setString(7, this->getCbd8210SerialNumber());
84 m_writeStmt->setString(8, this->getCaenBridgeType());
85 m_writeStmt->setInt(9, this->getCaenLinkNumber());
86 m_writeStmt->setInt(10, this->getCaenBoardNumber());
88 m_writeStmt->executeUpdate();
91 throw(std::runtime_error(
"ODJBH4Config::writeDB(): " +
e.getMessage()));
94 if (!this->fetchID()) {
95 throw(std::runtime_error(
"ODJBH4Config::writeDB: Failed to write"));
100 this->checkConnection();
102 if (
result->getId() == 0) {
103 throw(std::runtime_error(
"ODJBH4Config::fetchData(): no Id defined for this ODJBH4Config "));
108 "SELECT * FROM ECAL_Jbh4_CONFIGURATION "
109 " where ( jbh4_configuration_id = :1 or jbh4_tag=:2 )");
110 m_readStmt->setInt(1,
result->getId());
111 m_readStmt->setString(2,
result->getConfigTag());
112 ResultSet *rset = m_readStmt->executeQuery();
116 result->setId(rset->getInt(1));
117 result->setConfigTag(rset->getString(2));
119 result->setUseBuffer(rset->getInt(3));
120 result->setHalModuleFile(rset->getString(4));
121 result->setHalAddressTableFile(rset->getString(5));
122 result->setHalStaticTableFile(rset->getString(6));
123 result->setCbd8210SerialNumber(rset->getString(7));
124 result->setCaenBridgeType(rset->getString(8));
125 result->setCaenLinkNumber(rset->getInt(9));
126 result->setCaenBoardNumber(rset->getInt(10));
129 throw(std::runtime_error(
"ODJBH4Config::fetchData(): " +
e.getMessage()));
139 this->checkConnection();
142 Statement *stmt = m_conn->createStatement();
144 "SELECT jbh4_configuration_id FROM ecal_jbh4_configuration "
145 "WHERE jbh4_tag=:jbh4_tag ");
147 stmt->setString(1, getConfigTag());
149 ResultSet *rset = stmt->executeQuery();
152 m_ID = rset->getInt(1);
156 m_conn->terminateStatement(stmt);
158 throw(std::runtime_error(
"ODJBH4Config::fetchID: " +
e.getMessage()));