Skip to content

Commit

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

try (Connection con = ds.getConnection();
Statement stmt = con.createStatement()) {
try (Statement stmt = ds.getConnection().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 @@ -78,22 +74,18 @@ public MsgBean insertMsg() throws SQLException, NoSuchAlgorithmException {
public List<MsgBean> selectMsg() throws SQLException {
List<MsgBean> msglist = new ArrayList<>();

try (Connection con = ds.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(selectsql)) {
try (ResultSet rs = ds.getConnection().createStatement()
.executeQuery(selectsql)) {
logger.log(Level.INFO, "Select SQL: {0}", selectsql);
while (rs.next()) {
MsgBean msgbean = new MsgBean(MsgUtils.stringToInt(rs.getString("id")),
rs.getString("msg"), "Select");
MsgBean msgbean = new MsgBean(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 @@ -106,13 +98,9 @@ public void invalidateCache() {
@Override
public String deleteMsg() throws SQLException {

try (Connection con = ds.getConnection();
Statement stmt = con.createStatement()) {
try (Statement stmt = ds.getConnection().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 0748847

Please sign in to comment.