Solved

logic problems

Posted on 2006-10-26
10
173 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now