IoT DAS Frameworks - IT Infra Monitoring and Analytics/IOT_Applications/Performance_Dashboard_Application(Reference App)/source/SA-DashBoard/src/java/com/merit/dashboard/queryexecuter/QueryExecuter.java
public LinkedHashMap<String, String> generateJsonFromGivenQuery(String szQueryString,String[] headingNames,Connection dataBaseConnection){
				LinkedHashMap<String, String> szMetricTypemap=new LinkedHashMap<String, String>();

				try{
					 Statement stat2 = dataBaseConnection.createStatement();
					 String szMetricTypeValueJson="";
					 ResultSet rs4 = stat2.executeQuery(szQueryString);
					 while (rs4.next()) {
						String szConcatColumn="";
						szMetricTypeValueJson="";
						for(int i=0;i<headingNames.length-1;i++){
							if(!headingNames[headingNames.length-1].equals("Alert"))
								if(rs4.getString(headingNames[i])!=null)
								szConcatColumn=szConcatColumn+",\""+headingNames[i]+"\":\""+rs4.getString(headingNames[i])+"\"";
							szMetricTypeValueJson=szMetricTypeValueJson+","+rs4.getString(headingNames[i]);
						}
							szConcatColumn=szConcatColumn+",\""+headingNames[headingNames.length-1]+"\":\""+rs4.getString(headingNames[headingNames.length-1])+"\"";
							 szMetricTypemap.put(szMetricTypeValueJson.substring(1), szConcatColumn.substring(1));
						}
					dataBaseConnection=null;
					stat2=null;
				 }
				 catch (Exception e) {
					e.printStackTrace();
					log.error("DashBoard Generate Default Service and ResourceType \n"+e.getMessage());
				}
				 return szMetricTypemap;
			}
/**
	 * ***************************************************************************************************
	 * Here we are Executing both Ticket and Metric Query  one by one because both having
	 * different dataBase Connection and sending as LinkedHashMap
	 * @param szQueryString Query to be Executed
	 * @param headingNames Name of Columns in Executed Query
	 * @param dataBaseConnection Specific query specific Connection
	 * @return szMetricTypemap  return LinkedHashMap
	 * ***************************************************************************************************
	 */
Here we are Executing both Ticket and Metric Query  one by one because both having
different dataBase Connection and sending as LinkedHashMap
@param szQueryString Query to be Executed
@param headingNames Name of Columns in Executed Query
@param dataBaseConnection Specific query specific Connection
@return szMetricTypemap  return LinkedHashMap
Here we are Executing both Ticket and Metric Query one by one because both having different dataBase Connection and sending as LinkedHashMap @param szQueryString Query to be Executed @param headingNames Name of Columns in Executed Query @param dataBaseConnection Specific query specific Connection @return szMetricTypemap return LinkedHashMap
public LinkedHashMap<String, String> generateJsonFromGivenQuery(String szQueryString,String[] headingNames,Connection dataBaseConnection){
				LinkedHashMap<String, String> szMetricTypemap=new LinkedHashMap<String, String>();
				try{
					 Statement stat2 = dataBaseConnection.createStatement();
					 String szMetricTypeValueJson="";
					 ResultSet rs4 = stat2.executeQuery(szQueryString);
					 while (rs4.next()) {
						String szConcatColumn="";
						szMetricTypeValueJson="";
						for(int i=0;i<headingNames.length-1;i++){
							if(!headingNames[headingNames.length-1].equals("Alert"))
								if(rs4.getString(headingNames[i])!=null)
								szConcatColumn=szConcatColumn+",\""+headingNames[i]+"\":\""+rs4.getString(headingNames[i])+"\"";
							szMetricTypeValueJson=szMetricTypeValueJson+","+rs4.getString(headingNames[i]);
						}
							szConcatColumn=szConcatColumn+",\""+headingNames[headingNames.length-1]+"\":\""+rs4.getString(headingNames[headingNames.length-1])+"\"";
							 szMetricTypemap.put(szMetricTypeValueJson.substring(1), szConcatColumn.substring(1));
						}
					dataBaseConnection=null;
					stat2=null;
				 }
				 catch (Exception e) {
					e.printStackTrace();
					log.error("DashBoard Generate Default Service and ResourceType \n"+e.getMessage());
				}
				 return szMetricTypemap;
			}
public LinkedHashMap < String , String > generateJsonFromGivenQuery ( String szQueryString , String [ ] headingNames , Connection dataBaseConnection ) { LinkedHashMap < String , String > szMetricTypemap = new LinkedHashMap < String , String > ( ) ; try { Statement stat2 = dataBaseConnection . createStatement ( ) ; String szMetricTypeValueJson = "" ; ResultSet rs4 = stat2 . executeQuery ( szQueryString ) ; while ( rs4 . next ( ) ) { String szConcatColumn = "" ; szMetricTypeValueJson = "" ; for ( int i = 0 ; i < headingNames . length - 1 ; i ++ ) { if ( ! headingNames [ headingNames . length - 1 ] . equals ( "Alert" ) ) if ( rs4 . getString ( headingNames [ i ] ) != null ) szConcatColumn = szConcatColumn + ",\"" + headingNames [ i ] + "\":\"" + rs4 . getString ( headingNames [ i ] ) + "\"" ; szMetricTypeValueJson = szMetricTypeValueJson + "," + rs4 . getString ( headingNames [ i ] ) ; } szConcatColumn = szConcatColumn + ",\"" + headingNames [ headingNames . length - 1 ] + "\":\"" + rs4 . getString ( headingNames [ headingNames . length - 1 ] ) + "\"" ; szMetricTypemap . put ( szMetricTypeValueJson . substring ( 1 ) , szConcatColumn . substring ( 1 ) ) ; } dataBaseConnection = null ; stat2 = null ; } catch ( Exception e ) { e . printStackTrace ( ) ; log . error ( "DashBoard Generate Default Service and ResourceType \n" + e . getMessage ( ) ) ; } return szMetricTypemap ; }
Here we are Executing both Ticket and Metric Query  one by one because both having
 different dataBase Connection and sending as LinkedHashMap
 @param szQueryString Query to be Executed
 @param headingNames Name of Columns in Executed Query
 @param dataBaseConnection Specific query specific Connection
 @return szMetricTypemap  return LinkedHashMap
Here we are Executing both Ticket and Metric Query one by one because both having different dataBase Connection and sending as LinkedHashMap @param szQueryString Query to be Executed @param headingNames Name of Columns in Executed Query @param dataBaseConnection Specific query specific Connection @return szMetricTypemap return LinkedHashMap