Solved

logic problems

Posted on 2006-10-26
10
178 Views
Last Modified: 2010-04-01
i know its kind of sound crazy to post a logic isses under here.

But i do hope you guys can give me a hand

i have this data structure


masterlicenseid     renewid          dateofdownload        dateofrenewal        
7                              2                    18/6/2006                 4/7/2006
7                              3                    18/6/2006                 5/7/2006
100                          12                   23/8/2006                30/8/2006
143                          16                   18/9/2006                1/9/2006
143                           17                  18/9/2006                2/9/2006
143                           18                  18/9/2006                2/9/2006


i wish to diplat the above information like this in the web page

--------------------------------------------------------------------------------------
masterlicenseid       renewid          dateofdownload            dateofrenewal
---------------------------------------------------------------------------------------
7                           2                        18/6/2006                  4/7/2006
                             3                                                         5/7/2006
--------------------------------------------------------------------------------------
100                       12                      23/8/2006                   30/8/2006
-------------------------------------------------------------------------------------
143                      16                       18/9/2006                 1/9/2006
                            17                                                       2/9/2006
                           18                                                        3/9/2066


************

I am totally know how to perform a resultset caputre from the query to db. But i am not sure how can i make it separate basing on the masterlicenseid.

I am manage to group by using the masterlicenseid, but how can i pass the object back to JSP to display? a the renewedid is dynamic.

How would you tackle this? Please share with me.
0
Comment
Question by:chainreaction
10 Comments
 

Author Comment

by:chainreaction
ID: 17810197
this is my program

businessLogic.java

..
..
            stmt = dbConnect();
                  String query = "select * from renewedclientlicenses ";
                  rs = stmt.executeQuery(query);
                  while(rs.next()){
                        ob = new object();
                        ob.setDateOfDownload(rs.getString("dateofdownload"));
                        ob.setDateOfRenewal(rs.getString("dateofrenewal"));
                        ob.setMasterlicenseid(rs.getString("masterlicenseid"));
                        ob.setMobileNumber(rs.getString("mobileNumber"));
                        ob.setRenewedlicenseid(rs.getString("renewlicenseid"));
                        ob.setMonth(df.format(rs.getDate("dateofrenewal")));
                        result_list.add(ob);
                  }
..
..

jsp page
..
..
<%
dbConnection db = new dbConnection();
List data_list = db.getData();
object ob = null;
for (int i=0; i<data_list.size(); i++) {
ob = (object)data_list.get(i);
%>
<tr>
      <td><%= ob.getMasterlicenseid() %></td>
      <td><%= ob.getRenewedlicenseid() %></td>
      <td><%= ob.getMobileNumber() %></td>
      
      <td>
            <% if (ob.getMonth().equals("07")) { %>
                  <b>
                  <%= ob.getDateOfRenewal() %>
            </b>
            <% }  else { %>
                        <%= ob.getDateOfRenewal() %>
      <% } %>

..
..

the output is :

masterlicenId renewlicenseid      dateofrenewal            dateof download
7            31            2006-07-04 20:51:28.0      2006-06-18 20:51:42.0
7            32            2006-07-04 20:53:25.0      2006-06-18 20:51:42.0
64            303            2006-08-04 16:19:48.0      2006-06-21 15:25:14.0
64            25            2006-06-29 21:26:10.0      2006-06-21 15:25:14.0
95            215            2006-07-28 09:48:44.0      2006-06-22 09:19:50.0
95            38            2006-07-05 22:51:39.0      2006-06-22 09:19:50.0
143            1            2006-06-23 11:48:37.0      2006-06-22 11:44:15.0
152            152            2006-07-23 11:37:46.0      2006-06-22 12:06:43.0
152            153            2006-07-23 11:40:31.0      2006-06-22 12:06:43.0
      
0
 

Author Comment

by:chainreaction
ID: 17810200
but then i am expecting the output like this...

masterlicenId renewlicenseid      dateofrenewal            dateof download
7            31            2006-07-04 20:51:28.0      2006-06-18 20:51:42.0
            32            2006-07-04 20:53:25.0      2006-06-18 20:51:42.0
64            303            2006-08-04 16:19:48.0      2006-06-21 15:25:14.0
            25            2006-06-29 21:26:10.0      2006-06-21 15:25:14.0
95            215            2006-07-28 09:48:44.0      2006-06-22 09:19:50.0
            38            2006-07-05 22:51:39.0      2006-06-22 09:19:50.0
143            1            2006-06-23 11:48:37.0      2006-06-22 11:44:15.0
152            152            2006-07-23 11:37:46.0      2006-06-22 12:06:43.0
             153            2006-07-23 11:40:31.0      2006-06-22 12:06:43.0
0
 

Author Comment

by:chainreaction
ID: 17810204
can you share your ideas?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 16

Accepted Solution

by:
suprapto45 earned 360 total points
ID: 17810208
The simple logic would be like

Return query to JSP. The query must be order by masterlicenseid, renewid asc
1. set one temp variable to contain the value of masterlicenseid
1. Loop the result set
    2. if (QUERY(masterlicenseid) == temp)
        3. Do not print masterlicenseid and do not print date of download
    4. else
        5. Print everything
    6. Set the temp to the QUERY(masterlicenseid)
7. End loop

Try to post your current codes and we can have a look
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 17810215
Okay,

I saw your codes. Please try my logic and let me know if it does not work
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 17810252
Oppp...typo.

>>"set one temp variable to contain the value of masterlicenseid"
You can just set it as an empty String or 0 if it is int
0
 

Author Comment

by:chainreaction
ID: 17810357
supraptor45, i thought the above problem can be easily sovle by HTML Table code?
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 17810466
>>"can be easily sovle by HTML Table code"
What do you mean?

I do not really get you on this.
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17822908
use Display Tag  
see this for Display Tag
http://displaytag.sourceforge.net/11/

Display tag is very good tag library to display data in tables in your jsps'
0
 
LVL 8

Expert Comment

by:reach2piyush
ID: 17879827
String query = "select * from renewedclientlicenses order by masterlicenseid";

jsp page
..
..
<%
......
String lastRecord = "";
%>
<tr>
     <% if (lastRecord.equals(ob.getMasterlicenseid())) {%>
     <td><%= ob.getMasterlicenseid() %></td>
      <%
         }
         lastRecord = ob.getMasterlicenseid();
       %>
     .......
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
tomcat users xml 7 127
How to set default webapp for host 6 47
iterator/ListIterator approach 17 39
jsp login check 12 42
If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
IT certifications are a concrete representation of continual learning on the part of the candidate.  Continual learning is necessary for the long term success of an IT professional, but are IT certifications the right path for you?
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question