Solved

logic problems

Posted on 2006-10-26
10
176 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ajax auto save 15 98
html form inside div 3 90
issue with pdf generation 2 83
caughtSpeeding java challenge 16 134
If your vDisk VHD file gets deleted from the image store accidentally or on purpose, you won't be able to remove the vDisk from the PVS console. There is a known workaround that is solid.
Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

937 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

11 Experts available now in Live!

Get 1:1 Help Now