use prepared statement instead of string interpolation

This commit is contained in:
Xavier Léauté 2014-03-27 12:41:30 -07:00
parent e0ff2aa0d6
commit 6e18ff7ed4
1 changed files with 8 additions and 6 deletions

View File

@ -74,13 +74,15 @@ public class DatabaseRuleManager
@Override @Override
public Void withHandle(Handle handle) throws Exception public Void withHandle(Handle handle) throws Exception
{ {
List<Map<String, Object>> existing = handle.select( List<Map<String, Object>> existing = handle
String.format( .createQuery(
"SELECT id from %s where datasource='%s';", String.format(
ruleTable, "SELECT id from %s where datasource=:dataSource;",
defaultTier ruleTable
)
) )
); .bind("dataSource", defaultTier)
.list();
if (!existing.isEmpty()) { if (!existing.isEmpty()) {
return null; return null;