Fix findbugs SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING warning in Upgrade30xBase.java There was no risk of sql injection here, nor any need to use PreparedStatement, still, this fixes the warning

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #442
This commit is contained in:
Rafael da Fonseca 2015-06-14 19:17:14 +02:00 committed by Rohit Yadav
parent 869cc0c9f2
commit 4eaa613a0b

View File

@ -32,12 +32,13 @@ public abstract class Upgrade30xBase implements DbUpgrade {
final static Logger s_logger = Logger.getLogger(Upgrade30xBase.class);
protected String getNetworkLabelFromConfig(Connection conn, String name) {
String sql = "SELECT value FROM `cloud`.`configuration` where name = '" + name + "'";
String sql = "SELECT value FROM `cloud`.`configuration` where name = ?";
String networkLabel = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,name);
rs = pstmt.executeQuery();
if (rs.next()) {
networkLabel = rs.getString(1);