cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [1/2] git commit: updated refs/heads/master to 6e06855
Date Fri, 19 Jun 2015 21:26:13 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master e3407a393 -> 6e068551d


findbugs: use a prepared statement as prepared statement

Signed-off-by: Daan Hoogland <daan@onecht.net>

This closes #492


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6e068551
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6e068551
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6e068551

Branch: refs/heads/master
Commit: 6e068551d60b68288dd69e8248bcc5043e8e97e8
Parents: e713ed3
Author: Daan Hoogland <daan@onecht.net>
Authored: Fri Jun 19 15:08:23 2015 +0200
Committer: Daan Hoogland <daan@onecht.net>
Committed: Fri Jun 19 23:26:00 2015 +0200

----------------------------------------------------------------------
 server/src/com/cloud/test/PodZoneConfig.java | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e068551/server/src/com/cloud/test/PodZoneConfig.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/test/PodZoneConfig.java b/server/src/com/cloud/test/PodZoneConfig.java
index 4846fdf..16bc0a0 100644
--- a/server/src/com/cloud/test/PodZoneConfig.java
+++ b/server/src/com/cloud/test/PodZoneConfig.java
@@ -247,8 +247,17 @@ public class PodZoneConfig {
             saveVlan(zoneId, podId, vlanId, vlanGateway, vlanNetmask, vlanType, ipRange,
networkId, physicalNetworkDbId);
             if (podId != null) {
                 long vlanDbId = getVlanDbId(zone, vlanId);
-                String sql = "INSERT INTO `cloud`.`pod_vlan_map` (pod_id, vlan_db_id) " +
"VALUES ('" + podId + "','" + vlanDbId + "')";
-                DatabaseConfig.saveSQL(sql, "Failed to save pod_vlan_map due to exception
vlanDbId=" + vlanDbId + ", podId=" + podId + ". Please contact Cloud Support.");
+                String sql = "INSERT INTO `cloud`.`pod_vlan_map` (pod_id, vlan_db_id) " +
"VALUES (?,?)";
+                String errorMsg =  "Failed to save pod_vlan_map due to exception vlanDbId="
+ vlanDbId + ", podId=" + podId + ". Please contact Cloud Support.";
+                TransactionLegacy txn = TransactionLegacy.open("saveSQL");
+                try ( PreparedStatement stmt = txn.prepareAutoCloseStatement(sql); ) {
+                        stmt.setString(1, podId.toString());
+                        stmt.setString(2, String.valueOf(vlanDbId));
+                        stmt.executeUpdate();
+                    } catch (SQLException ex) {
+                        System.out.println("SQL Exception: " + ex.getMessage());
+                        printError(errorMsg);
+                    }
             }
 
             return genReturnList("true", "Successfully added VLAN.");


Mime
View raw message