You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ad...@apache.org on 2021/01/06 07:33:37 UTC

[roller] branch master updated: Fixed: sonarqube issue - Used try-with-resources for the PreparedStatement

This is an automated email from the ASF dual-hosted git repository.

adityasharma pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/roller.git


The following commit(s) were added to refs/heads/master by this push:
     new 701acc3  Fixed: sonarqube issue - Used try-with-resources for the PreparedStatement
701acc3 is described below

commit 701acc389ae3aab6ee171962d4066c4e73cc4cdf
Author: Aditya Sharma <ad...@apache.org>
AuthorDate: Wed Jan 6 13:03:15 2021 +0530

    Fixed: sonarqube issue - Used try-with-resources for the PreparedStatement
---
 .../apache/roller/weblogger/business/startup/DatabaseInstaller.java | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java b/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
index 257dde8..d370579 100644
--- a/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
+++ b/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
@@ -910,8 +910,7 @@ public class DatabaseInstaller {
     private void setDatabaseVersion(Connection con, int version)
             throws StartupException {
 
-        try {
-            PreparedStatement stmt = con.prepareStatement("insert into roller_properties values(?,?)");
+        try (PreparedStatement stmt = con.prepareStatement("insert into roller_properties values(?,?)")) {
             stmt.setString(1, DBVERSION_PROP);
             stmt.setString(2, String.valueOf(version));
             stmt.executeUpdate();
@@ -929,8 +928,7 @@ public class DatabaseInstaller {
     private void updateDatabaseVersion(Connection con, int version)
             throws StartupException {
 
-        try {
-            PreparedStatement stmt = con.prepareStatement("update roller_properties set value = ? where name = ?");
+        try (PreparedStatement stmt = con.prepareStatement("update roller_properties set value = ? where name = ?")) {
             stmt.setString(1, String.valueOf(version));
             stmt.setString(2, DBVERSION_PROP);
             stmt.executeUpdate();