Skip to content

Commit

Permalink
Revert " Assignment Branch Condition too high by codebeat #3049"
Browse files Browse the repository at this point in the history
This reverts commit 0748847.
  • Loading branch information
yurake committed Feb 15, 2023
1 parent 0748847 commit c3704a3
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ public MsgBean insertMsg() throws SQLException, NoSuchAlgorithmException {
String sql = insertsql.replace("msgid", MsgUtils.intToString(msgbean.getId()))
.replace("msgbody", msgbean.getMessage());

try (Statement stmt = ds.getConnection().createStatement()) {
try (Connection con = ds.getConnection();
Statement stmt = con.createStatement()) {
logger.log(Level.INFO, "Insert SQL: {0}", sql);
stmt.executeUpdate(sql);
} catch (SQLException e) {
logger.log(Level.SEVERE, "Insert Error.", e);
throw new SQLException("Insert Error.", e);
}
logger.log(Level.INFO, msgbean.getFullmsg());
return msgbean;
Expand All @@ -74,18 +78,22 @@ public MsgBean insertMsg() throws SQLException, NoSuchAlgorithmException {
public List<MsgBean> selectMsg() throws SQLException {
List<MsgBean> msglist = new ArrayList<>();

try (ResultSet rs = ds.getConnection().createStatement()
.executeQuery(selectsql)) {
try (Connection con = ds.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(selectsql)) {
logger.log(Level.INFO, "Select SQL: {0}", selectsql);
while (rs.next()) {
MsgBean msgbean = new MsgBean(rs.getString("id"), rs.getString("msg"),
"Select");
MsgBean msgbean = new MsgBean(MsgUtils.stringToInt(rs.getString("id")),
rs.getString("msg"), "Select");
logger.log(Level.INFO, msgbean.getFullmsg());
msglist.add(msgbean);
}
if (msglist.isEmpty()) {
msglist.add(new MsgBean(0, "No Data.", "Select"));
}
} catch (SQLException e) {
logger.log(Level.SEVERE, "Select Errorr.", e);
throw new SQLException("Select Error.", e);
}
return msglist;
}
Expand All @@ -98,9 +106,13 @@ public void invalidateCache() {
@Override
public String deleteMsg() throws SQLException {

try (Statement stmt = ds.getConnection().createStatement()) {
try (Connection con = ds.getConnection();
Statement stmt = con.createStatement()) {
logger.log(Level.INFO, "Delete SQL: {0}", deletesql);
stmt.executeUpdate(deletesql);
} catch (SQLException e) {
logger.log(Level.SEVERE, "Delete Errorr.", e);
throw new SQLException("Delete Error.", e);
}
return "Delete Msg Records";
}
Expand Down

0 comments on commit c3704a3

Please sign in to comment.