You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2015/06/18 11:15:39 UTC
[2/2] git commit: updated refs/heads/master to 5d258fa
Fix 2 findbugs SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING warnings in DatabaseConfig.java
Signed-off-by: Rajani Karuturi <ra...@gmail.com>
This closes #478
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5d258fa1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5d258fa1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5d258fa1
Branch: refs/heads/master
Commit: 5d258fa16311c95ea2b25863cbc58f9144f5c9f8
Parents: 2993291
Author: Rafael da Fonseca <rs...@gmail.com>
Authored: Wed Jun 17 21:43:50 2015 +0200
Committer: Rajani Karuturi <ra...@gmail.com>
Committed: Thu Jun 18 14:36:26 2015 +0530
----------------------------------------------------------------------
server/src/com/cloud/test/DatabaseConfig.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5d258fa1/server/src/com/cloud/test/DatabaseConfig.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/test/DatabaseConfig.java b/server/src/com/cloud/test/DatabaseConfig.java
index 1c9b0db..097fb99 100644
--- a/server/src/com/cloud/test/DatabaseConfig.java
+++ b/server/src/com/cloud/test/DatabaseConfig.java
@@ -1189,10 +1189,12 @@ public class DatabaseConfig {
sb.append(pwStr);
// create an account for the admin user first
- insertSql = "INSERT INTO `cloud`.`account` (id, account_name, type, domain_id) VALUES (" + id + ", '" + username + "', '1', '1')";
+ insertSql = "INSERT INTO `cloud`.`account` (id, account_name, type, domain_id) VALUES (?, ?, '1', '1')";
txn = TransactionLegacy.currentTxn();
try {
PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
+ stmt.setLong(1, id);
+ stmt.setString(2, username);
stmt.executeUpdate();
} catch (SQLException ex) {
s_logger.error("error creating account", ex);
@@ -1258,11 +1260,12 @@ public class DatabaseConfig {
"INSERT INTO `cloud`.`configuration` (instance, component, name, value, description, category) " + "VALUES ('" + instance + "','" + component + "','" + name +
"','" + value + "','" + description + "','" + category + "')";
- String selectSql = "SELECT name FROM cloud.configuration WHERE name = '" + name + "'";
+ String selectSql = "SELECT name FROM cloud.configuration WHERE name = ?";
TransactionLegacy txn = TransactionLegacy.currentTxn();
try {
PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
+ stmt.setString(1, name);
ResultSet result = stmt.executeQuery();
Boolean hasRow = result.next();
if (!hasRow) {