Monday, 15 March 2010

java - using loop get the hashmap values -


After

I have 5 properties in my database, I get it by using hashmap in my struts2 The project is trying. Properties are Marketplace , OrderDate , dataamount , counts names, results . Here I want to show the value of my jsp table, so that each market 3 period lines, which is of dataamount , count Result . Currently my Java Action Class looks like this.

  package com.action; Import java.sql.Connection; Import java.sql.ResultSet; Import java.sql.Statement; Import java.text.BreakItator; Import java.util.HashMap; Import java.util.Iterator; Import java.util.Map; Import com.action.GetCon; Import com.action.ReportClass; Import freemarker.debug.Breakpoint; Public Classroom JanuaryAction {Private String Name; Hashmap ABC = new Hashmap (); Public hashmap getAbc () {back abc; } Public Zero Set ABC (Hashmap ABC) {this.abc = abc; } Public string getName () {return name; } Public Zero Setname (string name) {this.name = name; } Public string executed () throws exceptions {String time = getName (); / * System.out.println (time); * / If (time.equals ("January 2013")) {abc.put (time, "2013-01-01" and order date & lt; = '2013-01-31 ");} and if ( Time.equals ("February 2013")) {abc.put (time, "'2013-02-01' and order date & lt; = '2013-02-31'");} and if (time.equals ( "March 2013")} {abc.put (time, "'2013-03-01' and order date & lt; = '2013-03-31'");} and if (time.file ("April 2013" )) {Abc.put (time, "'2013-04-01' and order date & lt; = '2013-04-31'");} Else if (time.equals ("May 2013")) {abc .put (time, "'2013-05-01' and order date & lt; = '2013-05-31'");} and if (time.file ("June 2013")) {abc.put (time) , "'2013-06-01' and order date & lt; = '2013-06-05'"};} string newtime = (string) abc.get (time); / * System.out.println ( Newtime); * / Connection con = GetCon.getCon (); Description Description = con.createStatement (); ResultSet resultset = statement.executeQuery ("Select Market, OrderDate, ROUND (Total (total), 2), COUNT (*) , ROUND (ROUND (totals (total), 2) / COUNT (*), 2) vend_printed ou order date = "+ new time +" group of order date, marketplace "); Object value = abc.remove (time); While (resultset.next ()) {string marketplace = resultset.getString (1); String orderdate = resultset.getString (2); Double DataMate = ResultsSet.Gate Double (3); Integer number = resultset.getInt (4); Double result = resultset.getDouble (5); Abc.put (0, market); String value 1 = (string) abc.get (0); Println (value1); Abc.put (1, order); String value 2 = (string) abc.get (1); Println (value 2); Abc.put (2, Datamant); Double value 3 = (double) abc.get (2); Println (value3); Abc.put (3, counting); Integer value 4 = (integer) abc.get (3); Println (VALUE4); Abc.put (4, results); Double value 5 = (double) abc.get (4); Println (value5); } Return "Success"; }}    

   & Lt; Br> & Lt; Br> The market name is: & lt; S: Property value = "% {# studentEntry.getKey ()}" /> & Lt; Br> Price: & lt; S: value of property = "% {# studentEntry.getValue ()}" /> & Lt; Br> & Lt; Br> & Lt; Br> & Lt; / S: iterator & gt;   

Hope it helps.

No comments:

Post a Comment