mirror of https://github.com/apache/cloudstack.git
Fix 2 findbugs SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING warnings in ConfigurationManagerImpl.java
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> This closes #476
This commit is contained in:
parent
b678b47793
commit
931cb95022
|
|
@ -926,7 +926,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
dbName = "cloud";
|
||||
}
|
||||
|
||||
String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + column + " = ?";
|
||||
String selectSql = "SELECT * FROM `?`.`?` WHERE ? = ?";
|
||||
|
||||
if(tableName.equals("vm_instance")) {
|
||||
selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "' AND removed IS NULL";
|
||||
|
|
@ -939,7 +939,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
final TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
try {
|
||||
final PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
|
||||
stmt.setLong(1, podId);
|
||||
stmt.setString(1,dbName);
|
||||
stmt.setString(2,tableName);
|
||||
stmt.setString(3,column);
|
||||
stmt.setLong(4, podId);
|
||||
final ResultSet rs = stmt.executeQuery();
|
||||
if (rs != null && rs.next()) {
|
||||
throw new CloudRuntimeException("The pod cannot be deleted because " + errorMsg);
|
||||
|
|
@ -1385,7 +1388,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
|
||||
final String dbName = "cloud";
|
||||
|
||||
String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + column + " = ?";
|
||||
String selectSql = "SELECT * FROM `?`.`?` WHERE ? = ?";
|
||||
|
||||
if (tableName.equals("op_dc_vnet_alloc")) {
|
||||
selectSql += " AND taken IS NOT NULL";
|
||||
|
|
@ -1410,7 +1413,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
final TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
try {
|
||||
final PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
|
||||
stmt.setLong(1, zoneId);
|
||||
stmt.setString(1,dbName);
|
||||
stmt.setString(2,tableName);
|
||||
stmt.setString(3,column);
|
||||
stmt.setLong(4, zoneId);
|
||||
final ResultSet rs = stmt.executeQuery();
|
||||
if (rs != null && rs.next()) {
|
||||
throw new CloudRuntimeException("The zone is not deletable because " + errorMsg);
|
||||
|
|
|
|||
Loading…
Reference in New Issue