import java.net.URISyntaxException;
import java.sql.*;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Map;

import javax.management.Query;

import com.heroku.sdk.jdbc.DatabaseUrl;

class IdealPrice 
{
	private ConnectData DB;
	private HashMap<String, NPD> DictNPD;
	private Account account;
	
	private Integer count = 0;
	private String QueryCmd = "";
	
	public IdealPrice(HashMap<String, NPD> newNPD)
	{
		DB = new ConnectData();
		DictNPD = newNPD;
		
		LoadData();
	}
	
	public IdealPrice(Account newAcc)
	{
		DB = new ConnectData();	
		account = newAcc;
		DictNPD = new HashMap<String, NPD>();
		
		try {
			ResultSet rs = DB.Query("SELECT * FROM salesforce.NPD__c where Account_Name__c='" + newAcc.Id + "'");
			/*
	        while (rs.next()) 	
	        {
	        	NPD newNPD = new NPD(rs);
	        	DictNPD.put(newNPD.Id, newNPD);
	        }
	        */
	        LoadData();
		} 
		catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	
	private void LoadData()
	{
		String listID = "";
		
		for(NPD npd : DictNPD.values())
		{
			listID += "'" + npd.Id + "', ";
		}
		listID = listID.length() > 2 ? listID.substring(0, listID.length() - 2) : listID;
		
		QueryCmd = "SELECT * FROM salesforce.Sourcing__c where NPD__c in (" + listID + ")";
		try 
		{
			count = 0;
			ResultSet rs = DB.Query("SELECT * FROM salesforce.Sourcing__c where NPD__c in (" + listID + ")");
			while (rs.next()) 
	        {
				FG newFG = new FG(rs);
				DictNPD.get(newFG.npdId).AddFG(newFG);
	        	//QueryCmd += "<br/>" + newFG.npdId;
				count++;
	        }
		} 
		catch (SQLException e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public String getResult()
	{
		String output = "Query: " + QueryCmd + "<br/> " + "Count: " + count + "<br/> ";
		for(NPD npd : DictNPD.values())
		{
			output += "NPD Id: " + npd.Id + "<br/>";
			
			for(FG fg : npd.listFG)
			{
				output += " - FG Name: " + fg.Name + ", MOQ: " + fg.MOQ1 + ", Annual: " + fg.AnnualVolume + ", Launch:" + fg.LaunchVolume + "<br/>";
			}
			
		}
		return output;
		//return "Success";
	}
}

@@ -738,10 +738,8 @@
 %0A%09%09%09
-/*
 %0A%09  
@@ -877,10 +877,8 @@
     
-*/
 %0A%09  
@@ -883,16 +883,18 @@
         
+//
 LoadData
@@ -897,16 +897,26 @@
 Data();%0A
+%09        %0A
 %09%09%7D %0A%09%09c
@@ -1749,24 +1749,30 @@
 Result()%0A%09%7B%0A
+%09%09%09/*%0A
 %09%09String out
@@ -2128,18 +2128,21 @@
 tput;%0A%09%09
-//
+*/%0A%09%09
 return %22

Test Connect DB Class on Ideal Price V.2