pstmt.setTimestamp(1, new Timestamp(r.getStartTime())); ResultSet rs = pstmt.executeQuery();
pstmt.setTimestamp(1, new Timestamp(startTime)); ResultSet rs = executeQuery(pstmt, query);
    private void populateAgent(ComponentData data, boolean isAdded) throws SQLException {        AgentAssetData assetData = data.getAgentAssetData();        if (assetData == null) return;        substitutions.put(":agent_org_class:", sqlQuote(assetData.getAssetClass()));        substitutions.put(":agent_lib_name:", sqlQuote(data.getName()));        if (isAdded) {            // finish populating a new agent            ResultSet rs = executeQuery(stmt, dbp.getQuery("checkAgentOrg", substitutions));            if (!rs.next()) {                executeUpdate(dbp.getQuery("insertAgentOrg", substitutions));            }            rs.close();            PropGroupData[] pgs = assetData.getPropGroups();            for (int i = 0; i < pgs.length; i++) {                PropGroupData pg = pgs[i];                String pgName = pg.getName();                PGPropData[] props = pg.getProperties();                for (int j = 0; j < props.length; j++) {                    PGPropData prop = props[i];                    PropertyInfo propInfo = getPropertyInfo(pgName, prop.getName());                    substitutions.put(":component_alib_id:", sqlQuote(getComponentAlibId(data)));                    substitutions.put(":pg_attribute_lib_id:", propInfo.getAttributeLibId());                    substitutions.put(":start_date:", sqlQuote("2000-01-01 00:00:00"));                    substitutions.put(":end_date:", sqlQuote(null));                    if (propInfo.isCollection()) {                        if (!prop.isListType())                            throw new RuntimeException("Property is not a collection: "                                                       + propInfo.toString());                        String[] values = ((PGPropMultiVal) prop.getValue()).getValuesStringArray();                        for (int k = 0; k < values.length; k++) {                            substitutions.put(":attribute_value:", sqlQuote(values[k]));                            substitutions.put(":attribute_order:", String.valueOf(k + 1));                            executeUpdate(dbp.getQuery("insertAttribute", substitutions));                        }                    } else {                        if (prop.isListType())                            throw new RuntimeException("Property is not a single value: "                                                       + propInfo.toString());                        substitutions.put(":attribute_value:", sqlQuote(prop.getValue().toString()));                        substitutions.put(":attribute_order:", "1");                        executeUpdate(dbp.getQuery("insertAttribute", substitutions));                    }                }            }        }        RelationshipData[] relationships = assetData.getRelationshipData();        //        dbp.setDebug(true);        for (int i = 0; i < relationships.length; i++) {            RelationshipData r = relationships[i];            long startTime = r.getStartTime();            long endTime = r.getEndTime();            substitutions.put(":role:", sqlQuote(r.getRole()));            substitutions.put(":supporting:", sqlQuote(getComponentAlibId(data)));            substitutions.put(":supported:", getAgentAlibId(r.getSupported()));            substitutions.put(":start_date:", "?");            substitutions.put(":end_date:", "?");            String query = dbp.getQuery("checkRelationship", substitutions);            PreparedStatement pstmt = dbConnection.prepareStatement(query);            pstmt.setTimestamp(1, new Timestamp(r.getStartTime()));            ResultSet rs = pstmt.executeQuery();            if (!rs.next()) {                query = dbp.getQuery("insertRelationship", substitutions);                PreparedStatement pstmt2 = dbConnection.prepareStatement(query);                pstmt2.setTimestamp(1, new Timestamp(startTime));                if (endTime > 0L) {                    pstmt2.setTimestamp(2, new Timestamp(endTime));                } else {                    pstmt2.setNull(2, Types.TIMESTAMP);                }                pstmt2.executeUpdate();                pstmt2.close();            }            pstmt.close();        }    }