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 Connection connection = null;
	private Statement stmt = null;
	private HashMap<String, NPD> DictNPD;
	private Account account;

	private String QueryCmd = "";
	private String listID = "";
	
	public IdealPrice(String listNPD)
	{	
		DictNPD = new HashMap<String, NPD>();		
		QueryCmd = "SELECT * FROM salesforce.NPD__c where NPD__c in (" + listNPD + ")";
        LoadData(QueryCmd);
	}
	
	public IdealPrice(Account newAcc)
	{
		account = newAcc;
		DictNPD = new HashMap<String, NPD>();

        QueryCmd = "SELECT * FROM salesforce.NPD__c where Account_Name__c='" + newAcc.Id + "'";
        LoadData(QueryCmd);
	}
	
	private void LoadData(String cmd)
	{
		try {
			ResultSet rs = DataManager.Query(cmd);
			Integer i = 1;
			listID = "ID: "; 
			while (rs.next()) 	
			{
				listID += " No." + i + " ";
				NPD newNPD = new NPD(rs);
				DictNPD.put(newNPD.Id, newNPD);
				listID += newNPD.Id + ", ";
				i += 1;
			}
			listID += "<br/>";
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			listID += "Catch : " + e1.getMessage();
			e1.printStackTrace();
		}
	}
	
	public String getResult()
	{
		String output = "Query: " + QueryCmd + "<br/> ";
		output += listID;
		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";
	}
}

@@ -991,24 +991,25 @@
 xt()) %09%0A%09%09%09%7B
+%09
 %0A%09%09%09%09listID 
@@ -1146,31 +1146,86 @@
 %0A%09%09%09
-%7D%0A%09%09%09listID += %22%3Cbr/%3E%22;
+%09rs.previous();%0A%09%09%09%09listID += rs.getString(%22SFID%22) + %22, %22;%0A%09%09%09%09rs.next();%0A%09%09%09%7D
 %0A%09%09%7D
@@ -1361,16 +1361,37 @@
 ();%0A%09%09%7D%0A
+%09%09listID += %22%3Cbr/%3E%22;%0A
 %09%7D%0A%09%0A%09pu

Restructure Object