String query;
query = null;
  private void addAgents(Experiment experiment,                         ArrayList nodes,                         AgentComponent[] agents,                         String trialId, String assemblyMatch) {    Iterator iter = nodes.iterator();    try {      Connection conn = DBUtils.getConnection();      Map substitutions = new HashMap();      substitutions.put(":trial_id", trialId);      substitutions.put(":assemblyMatch", assemblyMatch);      substitutions.put(":insertion_point", "Node.AgentManager.Agent");	        Statement stmt = conn.createStatement();      NodeComponent nodeComponent = null;      while(iter.hasNext()) {        String query;        ResultSet rs;        String nodeName = (String)iter.next();        nodeComponent = experiment.addNode(nodeName);        substitutions.put(":parent_name", nodeName);        substitutions.put(":comp_alib_id", nodeName);        // Get args of the node        Properties nodeProps = nodeComponent.getArguments();        getComponentArguments(stmt, substitutions, nodeProps);        // Query All Agents for each node.        // Loop Query for every node.        query = DBUtils.getQuery("queryComponents", substitutions);	//        System.out.println("Organizer: Get agents: " + query);        rs = stmt.executeQuery(query);        while(rs.next()) {          // Find AgentComponent.          String aName = rs.getString(1);          for (int i=0; i < agents.length; i++) {            AgentComponent ac = agents[i];            if (ac.getShortName().equals(aName)) {              nodeComponent.addAgent(ac);              //System.out.println("Organizer:  Adding agent named:  " + ac.getShortName());              break;            }	              } 	          }        rs.close();      }      stmt.close();      conn.close();       } catch (SQLException se) {      System.err.println("Caught SQL exception: " + se);      se.printStackTrace();    }  }