Displaying differences for changeset |
@@ -30,14 +30,10 @@ |
int padsurf_technique_score; |
int pdrift_technique_score; |
int AoAid; |
- private Connection conn; |
- private Statement statement; |
@Override |
// reading the inputs from the json file into input object and placing it in the arraylist |
protected void preProcess() throws Exception { |
- this.conn = null; |
- this.statement = null; |
JSONArray groups = getJSONArrayParam("components"); |
for (int i = 0; i < groups.length(); i++) { |
Map<String, JSONObject> group = JSONUtils.preprocess(groups.getJSONArray(i)); |
@@ -49,10 +45,10 @@ |
@Override |
protected String process() throws Exception { |
- conn = wqm.utils.WQMTools.getConnection("wqm", LOG); |
- conn.setAutoCommit(false); |
- statement = conn.createStatement(); |
- try { |
+ try ( |
+ Connection conn = wqm.utils.WQMTools.getConnection("wqm", LOG); |
+ Statement statement = conn.createStatement();) { |
+ conn.setAutoCommit(false); |
for (V1_0.Input ip : components) { |
String query = "SELECT ipm_technique_score FROM wqm_ipm_technique_scores WHERE ipm_technique_id=" + ip.plan_ipm_technique + "AND wqm_concern=" + "'" + "Pesticide Leaching" + "'"; |
ResultSet results = statement.executeQuery(query); |
@@ -87,15 +83,6 @@ |
} catch (SQLException se) { |
LOG.info("Did not open database for WQM-18!"); |
LOG.info(se.getMessage()); |
- } finally { |
- if (this.statement != null) { |
- this.statement.close(); |
- this.statement = null; |
- } |
- if (this.conn != null) { |
- this.conn.close(); |
- this.conn = null; |
- } |
} |
return EXEC_OK; |