aspose file tools*
The moose likes Java in General and the fly likes Help requested Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help requested" Watch "Help requested" New topic
Author

Help requested

R Mannam
Greenhorn

Joined: Jul 18, 2006
Posts: 7
I require assistance on a college project in Java. This is the situation. A webpage has already been designed which consists of a dropdownlistbox that displays 100 Intervention Codes & Names along with two textboxes where the user can input two different values namely P & F. There are 25 different users that enter intervention related data. Each individual user is given a login & pwd with which he/she can login and input the values. Not all interventions are mandatory for each user. A report shall be generated using java code. It should contain intervention code, intervention name, p & f. If say for example, the user enters the data in July, the report should display P & F of upto May in the first column, then P & F of June in the second column and the sum of first & second columns in the third one. If the user doesn't input a value for any intervention, 0 shall be displayed. Please advise how to code. Thanks.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Hi,

Welcome to JavaRanch!

Well, what do you have so far? What have you learned about Web applications?


[Jess in Action][AskingGoodQuestions]
R Mannam
Greenhorn

Joined: Jul 18, 2006
Posts: 7
This is the existing code:

import java.io.*;
import java.sql.*;
public class Details1{
public static void main(String args[]){
Connection con=null;
SelectDataApp1 s1=new SelectDataApp1();
//int i=0;
int p=s1.selectData();
String a_code1[]=new String[p];
String activity_name1[]=new String[p];
float phy1[]=new float[p];
float fin1[]=new float[p];
SelectDataApp2 s2=new SelectDataApp2();
String dcode="04";
int q=s2.selectData(dcode);
String a_code2[]=new String[q];
float phy2[]=new float[q];
float fin2[]=new float[q];
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:funds","budget0607","budget0607");
Statement st=con.createStatement();
String sql2="select a_code,activity_name from activity order by 'a_code'";
ResultSet rs=st.executeQuery(sql2);
for(int i=0;rs.next();i++){
//while(rs.next()){
a_code1[i]=rs.getString("a_code");
activity_name1[i]=rs.getString("activity_name");
//System.out.println(a_code[i]);
//System.out.println(activity_name[i]);
//i++;
}
/*for(int i=0;i<p;i++){
System.out.println(a_code[i]);
System.out.println(activity_name[i]);
}*/
st.close();
rs.close();
System.in.read();
}
catch(IOException ioe){
System.out.println(ioe.getMessage());
}
catch(SQLException sqle){
System.out.println(sqle.getMessage());
}
catch(ClassNotFoundException cnfe){
System.out.println(cnfe.getMessage());
}
catch(Exception e){
System.out.println(e.getMessage());
}
finally{
try{
if(con!=null){
con.close();
}
}
catch(SQLException sqle){
System.out.println(sqle.getMessage());
}
}

try{
//String dcode="11";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:funds","budget0607","budget0607");
Statement st1=con.createStatement();
String sql3="select a_code,sum(physical)phy,sum(financial)fin from expenditure where "+
"dt_code='"+dcode+"' group by a_code";
ResultSet rs1=st1.executeQuery(sql3);
for(int i=0;rs1.next();i++){
//while(rs1.next()){
a_code2[i]=rs1.getString("a_code");
phy2[i]=rs1.getFloat("phy");
fin2[i]=rs1.getFloat("fin");
//activity_name1[i]=rs1.getString("activity_name");
//System.out.println(a_code2[i]);
//System.out.println(phy2[i]);
//System.out.println(fin2[i]);
//i++;
}
/*for(int i=0;i<p;i++){
System.out.println(a_code[i]);
System.out.println(activity_name[i]);
}*/
st1.close();
rs1.close();
System.in.read();
}
catch(IOException ioe){
System.out.println(ioe.getMessage());
}
catch(SQLException sqle){
System.out.println(sqle.getMessage());
}
catch(ClassNotFoundException cnfe){
System.out.println(cnfe.getMessage());
}
catch(Exception e){
System.out.println(e.getMessage());
}
finally{
try{
if(con!=null){
con.close();
}
}
catch(SQLException sqle){
System.out.println(sqle.getMessage());
}
}


for(int i=0;i<p;i++){
for(int j=0;j<q;j++){
if(a_code1[i]!=a_code2[j]){
System.out.println(a_code2[j]);
System.out.println(phy2[j]);
System.out.println(fin2[j]);
}
}
System.out.println(a_code1[i]);
System.out.println(phy1[i]);
System.out.println(fin1[i]);
break;
}

}
}

I want the last three lines to be looped but when I do so, System.out.println(a_code2[j]);
System.out.println(phy2[j]);
System.out.println(fin2[j]);
are getting looped which is unwanted. Looking for improvements from the forum. Thanks.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3528
    
  15
I'm not quite sure what you are asking, but the problem may be that you are using != to compare two Strings. You should be using String.equals() method.
i.e.

should be


Does that help ?

If not, can you show us an example of what output you are expecting.
[ July 19, 2006: Message edited by: Joanne Neal ]

Joanne
R Mannam
Greenhorn

Joined: Jul 18, 2006
Posts: 7
Joanne, thanks very much for responding to my question.
This is the desired output. Values other than 0 must be taken at run time in the corresponding fields as mentioned earlier. I am anticipating an optimal solution in Java.

<HTML>
<BODY bgcolor='beige'>
<form name=f1 action='http://192.10.200.161:9001/funds/'>
<h1 align="center">Monthly Financial Statement </h1><br>
<table border=2 cellpadding=4>
<tr>
<td><b>District</td><td>Srikakulam</td>
<td colspan=2><b>Month/Year</b></td>
<td colspan=2>
<select name='d1'>
<option value='JAN' >JAN
<option value='FEB'>FEB
<option value='MAR'>MAR
<option value='APR'>APR
<option value='MAY'>MAY
<option value='JUN'>JUN
<option value='JUL'>JUL
<option value='AUG'>AUG
<option value='SEP'>SEP
<option value='OCT'>OCT
<option value='NOV'>NOV
<option value='DEC'>DEC
</select>
<select name='d2'>
<option value='2006' >2006
<option value='2007'>2007
</select>
</td>
<td colspan=2><b>Date of Submission<b></td>
<td colspan=2><input type=text name=t570 size=10></td>
</tr>
<tr></tr><br>
<tr>
<th rowspan=3 align=center>S.No</th>
<th rowspan=3 align=center>Activity</th>
<th rowspan=2 colspan=2 align=center>Approved AWP &<BR>B including spill<br>over</th>
<th colspan=6 align=center>Achievement for the year</th>
</tr>

<tr>

<td colspan=2 align=center><b>up to the end of<br>previous month<b></td>
<td colspan=2 align=center><b>During the <br>month<b></td>
<td colspan=2 align=center><b>Cumulative<br>during the<br>Financial year<b></td>

</tr>

<tr>
<td align=center><b>Phy</b></td>
<td align=center><b>Fin</b></td>
<td align=center><b>Phy</b></td>
<td align=center><b>Fin</b></td>
<td align=center><b>Phy</b></td>
<td align=center><b>Fin</b></td>
<td align=center><b>Phy</b></td>
<td align=center><b>Fin</b></td>
</tr>
<tr>
<td><b>A</b></td>
<td><b>Schools (Physical)</b></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>

</tr>
<tr>
<td>0.01</td>
<td>EGS to Primary</td>
<td>10</td>
<td>5.678199</td>
<td><input type=text name=t1 size=3 value=3></td>
<td><input type=text name=t2 size=3 value=0.954747></td>
<td><input type=text name=t3 size=3 value=1></td>
<td><input type=text name=t4 size=3 value=0.123222></td>
<td><input type=text name=t5 size=3 value=4></td>
<td><input type=text name=t6 size=3 value=1.077969></td>
</tr>
<tr>
<td>0.02</td>
<td>New Primary School (Physical)</td>
<td>0.00000</td>
<td>0.00000</td>
<td><input type=text name=t7 size=3 value=0.00000></td>
<td><input type=text name=t8 size=3 value=0.00000></td>
<td><input type=text name=t9 size=3 value=0.00000></td>
<td><input type=text name=t10 size=3 value=0.00000></td>
<td><input type=text name=t11 size=3 value=0.00000></td>
<td><input type=text name=t12 size=3 value=0.00000></td>
</tr>
<tr>
<td>0.03</td>
<td>New Upper Primary School</td>
<td>0.00000</td>
<td>0.00000</td>
<td><input type=text name=t7 size=3 value=0.00000></td>
<td><input type=text name=t8 size=3 value=0.00000></td>
<td><input type=text name=t9 size=3 value=0.00000></td>
<td><input type=text name=t10 size=3 value=0.00000></td>
<td><input type=text name=t11 size=3 value=0.00000></td>
<td><input type=text name=t12 size=3 value=0.00000></td>
</tr>
[ July 20, 2006: Message edited by: R Mannam ]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14144
    
  18

Originally posted by R Mannam:
Joanne, thanks very much for responding to my question.
This is the desired output. Values other than 0 must be taken at run time in the corresponding fields as mentioned earlier. I am anticipating an optimal solution in Java.

So did you try what Joanne suggested or not?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
R Mannam
Greenhorn

Joined: Jul 18, 2006
Posts: 7
Yes, I tried but that didn't work either.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help requested