private static ValueTypePair[][] loadGrazingSubbasinData(ValueTypePair[][] vtp, Statement inA, Statement inB, String subGrz, String grzArea) {
        ValueTypePair[][] vTemp = new ValueTypePair[vtp.length * 20][3];
        HashSet ids = new HashSet(), subs = new HashSet();
        int index = 0;
        for (ValueTypePair[] v : vtp) {
            ids.add(v[0].getPairValueAsInt());
        }
        try {
            ResultSet sRs = inA.executeQuery("SELECT * FROM " + subGrz + " ORDER BY grazing;");
            while(sRs.next()) {
                int subId = sRs.getInt(1);
                int grzId = sRs.getInt(2);
                if(ids.contains(grzId)) {
                    if(subs.contains(subId)) {
                    }
                    else {
                        subs.add(subId);
                        sRs = inA.executeQuery("SELECT * FROM " + subGrz + " WHERE subbasin = " + subId + ";");
                        int k = 0; 
                        IdValuePair[] iTempArea = new IdValuePair[vtp.length];
                        IdValuePair[] iTempPct = new IdValuePair[vtp.length];
                        while(sRs.next()) {
                            grzId = sRs.getInt(2);
                            //if(ids.contains(grzId)) {
                                ResultSet aRs = inB.executeQuery("SELECT * FROM " + grzArea + " WHERE id = " + grzId + ";");
                                iTempArea[k] = new IdValuePair(aRs.getInt(1), aRs.getDouble(2));
                                iTempPct[k] = new IdValuePair(sRs.getInt(2), sRs.getDouble(3));
                                k++;
                            //}
                            //else {
                           //     ResultSet aRs = inB.executeQuery("SELECT * FROM " + grzArea + " WHERE id = " + grzId + ";");
                           //     iTempArea[k] = new IdValuePair(aRs.getInt(1), aRs.getDouble(2));
                               //     iTempPct[k] = new IdValuePair(sRs.getInt(2), sRs.getDouble(3));
                           //     k++;
                            //}
                        }
                        IdValuePair[] grazeArea = new IdValuePair[k];
                        IdValuePair[] grazePct = new IdValuePair[k];
                        System.arraycopy(iTempArea, 0, grazeArea, 0, k);
                        System.arraycopy(iTempPct, 0, grazePct, 0, k);
                        double cost = calculateGrazingMeanCost(grazeArea, grazePct, vtp);
                        int year = 1991;
                        for(int i = 0; i < 20; i++) {
                            vTemp[index * 20 + i][0] = new ValueTypePair(subId, 1);
                            vTemp[index * 20 + i][1] = new ValueTypePair(year, 1);
                            vTemp[index * 20 + i][2] = new ValueTypePair(cost, 0);
                            year++;
                        }
                        index++;
                        sRs = inA.executeQuery("SELECT * FROM " + subGrz + " ORDER BY grazing;");
                    }
                }
            }
        } catch (SQLException e) {
            Logger.getLogger(BuildDB.class.getName()).log(Level.SEVERE, null, e);
        }
        ValueTypePair[][] vals = new ValueTypePair[index * 20][3];
        System.arraycopy(vTemp, 0, vals, 0, vals.length);
        return vals;
    }