Link to home
Start Free TrialLog in
Avatar of aman0711
aman0711

asked on

Optimizing JSP load time

Hi all,
         I have a jsp page thats displaying a table fetched from the Database. To get the desired output as presentation, I am using two SQL queries. This Page is taking too long to get load, atleast 34 seconds. Please suggest me a way to make it faster.
The code along with the Page snap shot and DB Schema are attached.
Someone suggested me a way to do it, but I couldnt figure out. heres the link for that:
https://www.experts-exchange.com/questions/23985310/Oracle-Query-Optimization.html
<%@ page import="java.text.DateFormat,java.text.SimpleDateFormat,java.util.*,java.sql.*" %>
<body>
<%
SimpleDateFormat df = new SimpleDateFormat("EEE - MMM d, yyyy");
Calendar origDay = Calendar.getInstance();
Calendar prevDay = (Calendar) origDay.clone();
prevDay.add (Calendar.DAY_OF_YEAR, -1);
%>
 
<%! public ArrayList getDays(){
 
ArrayList dateList = new ArrayList();
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
 
Calendar cal =  Calendar.getInstance();
dateFormat.format(cal.getTime());
 
for(int i =0; i <=6; i++)
{
cal.add(Calendar.DATE, -1);
dateList.add(dateFormat.format(cal.getTime()));
 
}
//System.out.println("Last seven date"  + dateList );
return dateList;
}
%>
<%
java.util.ArrayList days= getDays();
//out.print(days);
%>
<h5><b>Current Status as of <%= df.format(prevDay.getTime()) %></b></h5>
<table border="1" cellspacing="1" bgcolor="#FFFFFF" WIDTH=99%>
<tr>
<th><b>Channel Group</b></th>
<th><b> Metric </b></th>
<% for( int i=0; i<days.size(); i++){%>
<th ><%=days.get(i)%></th>
<%}%>
<th><b>Minimum SLA </b></th>
</tr>
<%
Connection conn= null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@sd.xyz.com:T02","user", "pass");
 
String sql= "",sqldata="" ;
PreparedStatement pstmt= null,pstmtdata=null;
ResultSet rs = null , rsdata=null;
 
 
try{
sql ="SELECT CHANNELGROUP FROM  SLAND.METRICPAGE_TABLE GROUP BY CHANNELGROUP ORDER BY CHANNELGROUP ";
 
pstmt= conn.prepareStatement(sql);
rs= pstmt.executeQuery(sql);
 
while(rs.next()){
ArrayList success = new ArrayList();
ArrayList volume  =  new ArrayList();
ArrayList hightlight  =  new ArrayList();
// here
sqldata="select SUCCESS_RATE , VOLUME, NVL(to_char(D, 'mm/dd/yyyy'),' ') EASTCOAST_DATE from  SLAND.METRICPAGE_TABLE, ( SELECT TRUNC(SYSDATE) - LEVEL + 1 D FROM DUAL CONNECT BY LEVEL <=7) where CHANNELGROUP(+) ='"+rs.getString(1)+"' and EASTCOAST_DATE(+) = D order by D desc";
pstmtdata= conn.prepareStatement(sqldata);
//pstmtdata.setString(1,rs.getString(1));
rsdata= pstmtdata.executeQuery(sqldata);
%>
 
<tr>
<th rowspan=2 ><%=rs.getString(1)%></th>
 
<td> success </td>
<%
while(rsdata.next()){
 
float f = rsdata.getFloat(1);
if( f < 87 )
hightlight.add(new Integer(1)); // true
else
hightlight.add(new Integer(0)); // false
success.add(new Float(f)) ;
 
volume.add( new Integer(rsdata.getInt(2)));
//System.out.println(rs.getString(1)+"---"+ rsdata.getInt(1)+ "----"+ rsdata.getInt(2)+ "----"+ rsdata.getDate(3)   );
}
for(int s=0; s < success.size(); s++  ){
 
int h = ((Integer)hightlight.get(s)).intValue();
if(h==1)
out.print("<td style='background-color:#E33740'>"+success.get(s)+"%</span></td>")  ;
else
out.print("<td>"+success.get(s)+"%</td>")  ;
 
}
out.print("<td>"+87+"</td>");
%>
<td></td>
</tr>
<tr>
<td>volume </td>
 
<% for(int v=0; v < volume.size(); v++  ){
 
out.print("<td>"+volume.get(v)+"</td>")  ;
}
 
volume=null;
success=null;
 
}
 
//System.out.println(mdata);
conn.close();
rs.close();
rsdata.close();
pstmt.close();
pstmtdata.close();
}catch(Exception e){
 
e.printStackTrace();
conn=null;
 
}%>
 
</table>

Open in new window

md.bmp
md-sch.JPG
Avatar of Kuldeepchaturvedi
Kuldeepchaturvedi
Flag of United States of America image

I have not tested the code yet so chances are that it will blow up.. but the logic should be correct..
I have used the query from your previous question and then have tried to make two loops without firing 2 queries... try it and see how it goes..
<%@ page import="java.text.DateFormat,java.text.SimpleDateFormat,java.util.*,java.sql.*" %>
<html>
<body>
<%
SimpleDateFormat df = new SimpleDateFormat("EEE - MMM d, yyyy");
Calendar origDay = Calendar.getInstance();
Calendar prevDay = (Calendar) origDay.clone();
prevDay.add (Calendar.DAY_OF_YEAR, -1);
%>
 
<%! public ArrayList getDays(){
 
ArrayList dateList = new ArrayList();
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
 
Calendar cal =  Calendar.getInstance();
dateFormat.format(cal.getTime());
 
for(int i =0; i <=6; i++)
{
cal.add(Calendar.DATE, -1);
dateList.add(dateFormat.format(cal.getTime()));
 
}
return dateList;
}
%>
<%
java.util.ArrayList days= getDays();
%>
<h5><b>Current Status as of <%= df.format(prevDay.getTime()) %></b></h5>
<table border="1" cellspacing="1" bgcolor="#FFFFFF" WIDTH=99%>
<tr>
<th><b>Channel Group</b></th>
<th><b> Metric </b></th>
<% for( int i=0; i<days.size(); i++){%>
<th ><%=days.get(i)%></th>
<%}%>
<th><b>Minimum SLA </b></th>
</tr>
<%
Connection conn= null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@sd.xyz.com:T02","user", "pass");
 
String sql= "",sqldata="" ;
PreparedStatement pstmt= null,pstmtdata=null;
ResultSet rs = null , rsdata=null;
 
 
try{
sql ="SELECT chgroup, (rate || '%') SUCCESS_RATE, VOLUME, NVL(TO_CHAR(d, 'mm/dd/yyyy'), ' ') EASTCOAST_DATE from  SLAND.METRICPAGE_TABLE, (    SELECT TRUNC(SYSDATE) - LEVEL + 1 d
                            FROM DUAL
                      CONNECT BY LEVEL <= 7)
   WHERE  date(+) = d
ORDER BY chgroup, d DESC"; 
pstmt= conn.prepareStatement(sql);
rs= pstmt.executeQuery(sql);
ArrayList success = new ArrayList();
ArrayList volume  =  new ArrayList();
ArrayList hightlight  =  new ArrayList();
if(rs.next()){
String chggrp =rs.getString(1);
%>
boolean loop=true;
boolean innerloop=true;
while(loop){
boolean innerloop=true;
<tr>
<th rowspan=2 ><%=chggrp%></th>
<td> success </td>
 
while(innerloop)
{
	float f = rs.getFloat(2);
if( f < 87 )
	hightlight.add(new Integer(1)); // true
else
	hightlight.add(new Integer(0)); // false
success.add(new Float(f)) ;
volume.add( new Integer(rsdata.getInt(3)));
if(!rs.next())
{
innerloop=false;
loop=false;
}
if(!rs.getString(1).equals(chggrp))
innerloop=false;
chggrp=rs.getString(1);
}
for(int s=0; s < success.size(); s++  ){
 
int h = ((Integer)hightlight.get(s)).intValue();
if(h==1)
out.print("<td style='background-color:#E33740'>"+success.get(s)+"%</span></td>")  ;
else
out.print("<td>"+success.get(s)+"%</td>")  ;
}
out.print("<td>"+87+"</td>");
%>
<td></td>
</tr>
<tr>
<td>volume </td>
 
<% for(int v=0; v < volume.size(); v++  ){
 
out.print("<td>"+volume.get(v)+"</td>")  ;
}
 
volume=null;
success=null;
 
}
 
//System.out.println(mdata);
conn.close();
rs.close();
rsdata.close();
pstmt.close();
pstmtdata.close();
}catch(Exception e){
 
e.printStackTrace();
conn=null;
 
}%>
 
</table>
</body>
</html>

Open in new window

I don't get the purpose of the first query, I feel you can join the two queries and get the data in one go rather than hitting the database twice
Avatar of aman0711
aman0711

ASKER

Tried to run it,
This is what I got:

ORA-00936: missing expression
 
hi humanonomics:,
  I tried that, if you could see the link I posted in the question, its fetching a different output.
ORA-00936: missing expression

most probably the query is   not right... try to copy that query from your previous question, it should be fixing the error.
that query is:

select SUCCESS_RATE , VOLUME, NVL(to_char(D, 'mm/dd/yyyy'),' ') EASTCOAST_DATE from VSLAND.APM_WEB_QKPAY_METRICPAGE_V, ( SELECT TRUNC(SYSDATE) - LEVEL + 1 D FROM DUAL CONNECT BY LEVEL <=7) where CHANNELGROUP(+) ='"+rs.getString(1)+"' and EASTCOAST_DATE(+) = D order by D desc
and in this query I am passing the result set of previous Select query for grouping.
Did you try this query ?

select CHANNELGROUP , SUCCESS_RATE , VOLUME, NVL(to_char(D, 'mm/dd/yyyy'),' ') EASTCOAST_DATE from VSLAND.APM_WEB_QKPAY_METRICPAGE_V, ( SELECT TRUNC(SYSDATE) - LEVEL + 1 D FROM DUAL CONNECT BY LEVEL <=7) EASTCOAST_DATE(+) = D group by CHANNELGROUP order by CHANNELGROUP , D desc
Hi Humanonomics:
I tried your query. got an exception:

ORA-00933: SQL command not properly ended
ok try this:

select CHANNELGROUP , SUCCESS_RATE , VOLUME, NVL(to_char(D, 'mm/dd/yyyy'),' ') EASTCOAST_DATE from VSLAND.APM_WEB_QKPAY_METRICPAGE_V, ( SELECT TRUNC(SYSDATE) - LEVEL + 1 D FROM DUAL CONNECT BY LEVEL <=7) WHERE EASTCOAST_DATE(+) = D group by CHANNELGROUP order by CHANNELGROUP , D desc
this the query I was trying to put in your code.. ( it is copy paste from your previous question.. obviously I had changed the column names to match)

SELECT chgroup, (rate || '%') rate, volume, NVL(TO_CHAR(d, 'mm/dd/yyyy'), ' ') date
    FROM table_name, (    SELECT TRUNC(SYSDATE) - LEVEL + 1 d
                            FROM DUAL
                      CONNECT BY LEVEL <= 7)
   WHERE  date(+) = d
ORDER BY chgroup, d DESC

@ humanonomics:
This time a different exception :(

   ORA-00979: not a GROUP BY expression
 
how about this one ?

First try this out on the SQL prompt.

select CHANNELGROUP , SUCCESS_RATE , VOLUME, NVL(to_char(D, 'mm/dd/yyyy'),' ') EASTCOAST_DATE from VSLAND.APM_WEB_QKPAY_METRICPAGE_V, ( SELECT TRUNC(SYSDATE) - LEVEL + 1 D FROM DUAL CONNECT BY LEVEL <=7) WHERE EASTCOAST_DATE(+) = D order by CHANNELGROUP , D desc
@ kuldeep Sir,
          That query worked fine but a weird output :)
and I have attached the console output too

[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R java.lang.NullPointerException
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm._jsp._test._jspService(_test.java:147)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
[1/5/09 12:20:30:224 CST] 0000003b SystemErr     R 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R java.lang.NullPointerException
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm._jsp._test._jspService(_test.java:147)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
[1/5/09 12:20:53:061 CST] 0000003b SystemErr     R 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)

Open in new window

snap.JPG
Hi Humanonomics:
          This query worked fine. but its not grouping the Chgroups.
what this query is giving me is :
AAA
AAA
AAA
AAA
instead of a singler AAA with 7 dates in front of it as u can see in the snap shot
Hmmm:

select DISTINCT CHANNELGROUP , SUCCESS_RATE , VOLUME, NVL(to_char(D, 'mm/dd/yyyy'),' ') EASTCOAST_DATE from VSLAND.APM_WEB_QKPAY_METRICPAGE_V, ( SELECT TRUNC(SYSDATE) - LEVEL + 1 D FROM DUAL CONNECT BY LEVEL <=7) WHERE EASTCOAST_DATE(+) = D order by CHANNELGROUP , D desc
oops my fault.. in my code linenumber 64.. there is any extra closing tag of jsp ( %>).. thats what is messing it up.
I took that off and got bunch of errors :)
HTTP Error Code:   500
 
 
Error Message:/jsp/test.jsp(66,16) JSPG0060E: Invalid jsp syntax [Connection conn= null;Class.forName("oracle.jdbc.driver.OracleDriver");conn=DriverManager.getConnection("jdbc:oracle:thin:@mlpi148.sfdc.sbc.com:1522:osfd002","vsland", "mt_vsland"); String sql= "",sqldata="" ;PreparedStatement pstmt= null,pstmtdata=null;ResultSet rs = null , rsdata=null;  try{sql ="select CHANNELGROUP , SUCCESS_RATE , VOLUME, NVL(to_char(D, 'mm/dd/yyyy'),' ') EASTCOAST_DATE from VSLAND.APM_WEB_QKPAY_METRICPAGE_V, ( SELECT TRUNC(SYSDATE) - LEVEL + 1 D FROM DUAL CONNECT BY LEVEL &lt;=7) WHERE EASTCOAST_DATE(+) = D order by CHANNELGROUP , D desc"; pstmt= conn.prepareStatement(sql);rs= pstmt.executeQuery(sql);ArrayList success = new ArrayList();ArrayList volume  =  new ArrayList();ArrayList hightlight  =  new ArrayList();if(rs.next()){String chggrp =rs.getString(1);boolean loop=true;boolean innerloop=true;while(loop){boolean innerloop=true;&lt;tr&gt;&lt;th rowspan=2 &gt;]
 
Root Cause:com.ibm.ws.jsp.JspCoreException: /jsp/test.jsp(66,16) JSPG0060E: Invalid jsp syntax [Connection conn= null;Class.forName("oracle.jdbc.driver.OracleDriver");conn=DriverManager.getConnection("jdbc:oracle:thin:@mlpi148.sfdc.sbc.com:1522:osfd002","vsland", "mt_vsland"); String sql= "",sqldata="" ;PreparedStatement pstmt= null,pstmtdata=null;ResultSet rs = null , rsdata=null;  try{sql ="select CHANNELGROUP , SUCCESS_RATE , VOLUME, NVL(to_char(D, 'mm/dd/yyyy'),' ') EASTCOAST_DATE from VSLAND.APM_WEB_QKPAY_METRICPAGE_V, ( SELECT TRUNC(SYSDATE) - LEVEL + 1 D FROM DUAL CONNECT BY LEVEL &lt;=7) WHERE EASTCOAST_DATE(+) = D order by CHANNELGROUP , D desc"; pstmt= conn.prepareStatement(sql);rs= pstmt.executeQuery(sql);ArrayList success = new ArrayList();ArrayList volume  =  new ArrayList();ArrayList hightlight  =  new ArrayList();if(rs.next()){String chggrp =rs.getString(1);boolean loop=true;boolean innerloop=true;while(loop){boolean innerloop=true;&lt;tr&gt;&lt;th rowspan=2 &gt;]	at com.ibm.ws.jsp.translator.document.Jsp2Dom.getJspDocumentAsJspPage(Jsp2Dom.java:290)	at com.ibm.ws.jsp.translator.document.Jsp2Dom.getJspDocument(Jsp2Dom.java:170)	at com.ibm.ws.jsp.translator.JspTranslator.<init>(JspTranslator.java:67)	at com.ibm.ws.jsp.translator.JspTranslatorFactory.createTranslator(JspTranslatorFactory.java:112)	at com.ibm.ws.jsp.translator.utils.JspTranslatorUtil.translateJsp(JspTranslatorUtil.java:180)	at com.ibm.ws.jsp.translator.utils.JspTranslatorUtil.translateJspAndCompile(JspTranslatorUtil.java:83)	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.translateJsp(AbstractJSPExtensionServletWrapper.java:349)	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper._checkForTranslation(AbstractJSPExtensionServletWrapper.java:317)	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.checkForTranslation(AbstractJSPExtensionServletWrapper.java:226)	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:131)	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)	at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
 

Open in new window

@ Humanonomics:

 ORA-01791: not a SELECTed expression

 
If only I can keep my opening & closing jsp tags in line..!!
<%@ page import="java.text.DateFormat,java.text.SimpleDateFormat,java.util.*,java.sql.*" %>
<html>
<body>
<%
SimpleDateFormat df = new SimpleDateFormat("EEE - MMM d, yyyy");
Calendar origDay = Calendar.getInstance();
Calendar prevDay = (Calendar) origDay.clone();
prevDay.add (Calendar.DAY_OF_YEAR, -1);
%>
 
<%! public ArrayList getDays(){
 
ArrayList dateList = new ArrayList();
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
 
Calendar cal =  Calendar.getInstance();
dateFormat.format(cal.getTime());
 
for(int i =0; i <=6; i++)
{
cal.add(Calendar.DATE, -1);
dateList.add(dateFormat.format(cal.getTime()));
 
}
return dateList;
}
%>
<%
java.util.ArrayList days= getDays();
%>
<h5><b>Current Status as of <%= df.format(prevDay.getTime()) %></b></h5>
<table border="1" cellspacing="1" bgcolor="#FFFFFF" WIDTH=99%>
<tr>
<th><b>Channel Group</b></th>
<th><b> Metric </b></th>
<% for( int i=0; i<days.size(); i++){%>
<th ><%=days.get(i)%></th>
<%}%>
<th><b>Minimum SLA </b></th>
</tr>
<%
Connection conn= null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@sd.xyz.com:T02","user", "pass");
 
String sql= "",sqldata="" ;
PreparedStatement pstmt= null,pstmtdata=null;
ResultSet rs = null , rsdata=null;
 
 
try{
sql ="SELECT chgroup, (rate || '%') SUCCESS_RATE, VOLUME, NVL(TO_CHAR(d, 'mm/dd/yyyy'), ' ') EASTCOAST_DATE from  SLAND.METRICPAGE_TABLE, (    SELECT TRUNC(SYSDATE) - LEVEL + 1 d
                            FROM DUAL
                      CONNECT BY LEVEL <= 7)
   WHERE  date(+) = d
ORDER BY chgroup, d DESC"; 
pstmt= conn.prepareStatement(sql);
rs= pstmt.executeQuery(sql);
ArrayList success = new ArrayList();
ArrayList volume  =  new ArrayList();
ArrayList hightlight  =  new ArrayList();
if(rs.next()){
String chggrp =rs.getString(1);
boolean loop=true;
while(loop){
boolean innerloop=true;
%>
<tr>
<th rowspan=2 ><%=chggrp%></th>
<td> success </td>
<%
while(innerloop)
{
	float f = rs.getFloat(2);
if( f < 87 )
	hightlight.add(new Integer(1)); // true
else
	hightlight.add(new Integer(0)); // false
success.add(new Float(f)) ;
volume.add( new Integer(rsdata.getInt(3)));
if(!rs.next())
{
innerloop=false;
loop=false;
}
if(!rs.getString(1).equals(chggrp))
innerloop=false;
chggrp=rs.getString(1);
}
for(int s=0; s < success.size(); s++  ){
 
int h = ((Integer)hightlight.get(s)).intValue();
if(h==1)
out.print("<td style='background-color:#E33740'>"+success.get(s)+"%</span></td>")  ;
else
out.print("<td>"+success.get(s)+"%</td>")  ;
}
out.print("<td>"+87+"</td>");
%>
<td></td>
</tr>
<tr>
<td>volume </td>
 
<% for(int v=0; v < volume.size(); v++  ){
 
out.print("<td>"+volume.get(v)+"</td>")  ;
}
 
volume=null;
success=null;
 
}
 
//System.out.println(mdata);
conn.close();
rs.close();
rsdata.close();
pstmt.close();
pstmtdata.close();
}catch(Exception e){
 
e.printStackTrace();
conn=null;
 
}%>
 
</table>
</body>
</html>

Open in new window

select DISTINCT (CHANNELGROUP), SUCCESS_RATE , VOLUME, NVL(to_char(D, 'mm/dd/yyyy'),' ') EASTCOAST_DATE from VSLAND.APM_WEB_QKPAY_METRICPAGE_V, ( SELECT TRUNC(SYSDATE) - LEVEL + 1 D FROM DUAL CONNECT BY LEVEL <=7) WHERE EASTCOAST_DATE(+) = D order by CHANNELGROUP , D desc
@ Kuldeep Sir,
                           Its giving the red marker right on " } " present at line 121 on the above code.
   

Error Message:JSPG0049E: /jsp/test.jsp failed to compile : JSPG0091E: An error occurred at line: 117 in the file: /jsp/test.jspJSPG0093E: Generated servlet error from file: /jsp/test.jsp C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\temp\ILCDTD01AS3567BNode01\server1\metdal\apmQpay.war\jsp\_test.java : 183 : Syntax error, insert "else Statement" to complete IfStatementJSPG0091E: An error occurred at line: 117 in the file: /jsp/test.jspJSPG0093E: Generated servlet error from file: /jsp/test.jsp C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\temp\ILCDTD01AS3567BNode01\server1\metdal\apmQpay.war\jsp\_test.java : 183 : Syntax error, insert "}" to complete BlockC:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\temp\ILCDTD01AS3567BNode01\server1\metdal\apmQpay.war\jsp\_test.java : 204 : Syntax error on token "}", delete this tokenC:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\temp\ILCDTD01AS3567BNode01\server1\metdal\apmQpay.war\jsp\_test.java : 205 : Syntax error, insert "}" to complete ClassBody
 
Root Cause:com.ibm.ws.jsp.JspCoreException: JSPG0049E: /jsp/test.jsp failed to compile : JSPG0091E: An error occurred at line: 117 in the file: /jsp/test.jspJSPG0093E: Generated servlet error from file: /jsp/test.jsp C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\temp\ILCDTD01AS3567BNode01\server1\metdal\apmQpay.war\jsp\_test.java : 183 : Syntax error, insert "else Statement" to complete IfStatementJSPG0091E: An error occurred at line: 117 in the file: /jsp/test.jspJSPG0093E: Generated servlet error from file: /jsp/test.jsp C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\temp\ILCDTD01AS3567BNode01\server1\metdal\apmQpay.war\jsp\_test.java : 183 : Syntax error, insert "}" to complete BlockC:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\temp\ILCDTD01AS3567BNode01\server1\metdal\apmQpay.war\jsp\_test.java : 204 : Syntax error on token "}", delete this tokenC:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\temp\ILCDTD01AS3567BNode01\server1\metdal\apmQpay.war\jsp\_test.java : 205 : Syntax error, insert "}" to complete ClassBody	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.translateJsp(AbstractJSPExtensionServletWrapper.java:352)	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper._checkForTranslation(AbstractJSPExtensionServletWrapper.java:317)	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.checkForTranslation(AbstractJSPExtensionServletWrapper.java:226)	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:131)	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)	at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
 

Open in new window

Hi Humanonomics:
 Again the same error: ORA-01791: not a SELECTed expression
I am sorry guys, You are my last lope. this is the second time I am posting :(
 
try checking all the opening and closing brackets ( i.e.  all the { & } are properly matched)..

I will be back in 1 hr or so

Alright Sir, Thanks :)
okay found it..
I had not closed one if condition

if(rs.next()){
String chggrp =rs.getString(1);

after that line put a closing tag
if(rs.next()){
String chggrp =rs.getString(1);
}

also put a break in another if condition
if(!rs.next())
{
innerloop=false;
loop=false;
break;
}

<%@ page import="java.text.DateFormat,java.text.SimpleDateFormat,java.util.*,java.sql.*" %>
<html>
<body>
<%
SimpleDateFormat df = new SimpleDateFormat("EEE - MMM d, yyyy");
Calendar origDay = Calendar.getInstance();
Calendar prevDay = (Calendar) origDay.clone();
prevDay.add (Calendar.DAY_OF_YEAR, -1);
%>
 
<%! public ArrayList getDays(){
 
ArrayList dateList = new ArrayList();
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
 
Calendar cal =  Calendar.getInstance();
dateFormat.format(cal.getTime());
 
for(int i =0; i <=6; i++)
{
cal.add(Calendar.DATE, -1);
dateList.add(dateFormat.format(cal.getTime()));
 
}
return dateList;
}
%>
<%
java.util.ArrayList days= getDays();
%>
<h5><b>Current Status as of <%= df.format(prevDay.getTime()) %></b></h5>
<table border="1" cellspacing="1" bgcolor="#FFFFFF" WIDTH=99%>
<tr>
<th><b>Channel Group</b></th>
<th><b> Metric </b></th>
<% for( int i=0; i<days.size(); i++){%>
<th ><%=days.get(i)%></th>
<%}%>
<th><b>Minimum SLA </b></th>
</tr>
<%
Connection conn= null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@sd.xyz.com:T02","user", "pass");
 
String sql= "",sqldata="" ;
PreparedStatement pstmt= null,pstmtdata=null;
ResultSet rs = null , rsdata=null;
 
 
try{
sql ="SELECT CHANNELGROUP, SUCCESS_RATE, VOLUME, NVL(TO_CHAR(d, 'mm/dd/yyyy'), ' ') EASTCOAST_DATE from  VSLAND.APM_WEB_QKPAY_METRICPAGE_V, (SELECT TRUNC(SYSDATE) - LEVEL + 1 d FROM DUAL CONNECT BY LEVEL <= 7) WHERE  EASTCOAST_DATE(+) = d ORDER BY CHANNELGROUP, d DESC"; 
pstmt= conn.prepareStatement(sql);
rs= pstmt.executeQuery(sql);
ArrayList success = new ArrayList();
ArrayList volume  =  new ArrayList();
ArrayList hightlight  =  new ArrayList();
if(rs.next()){
String chggrp =rs.getString(1);
}
boolean loop=true;
while(loop){
boolean innerloop=true;
%>
<tr>
<th rowspan=2 ><%=chggrp%></th>
<td> success </td>
<%
while(innerloop)
{
	float f = rs.getFloat(2);
if( f < 87 )
	hightlight.add(new Integer(1)); // true
else
	hightlight.add(new Integer(0)); // false
success.add(new Float(f)) ;
volume.add( new Integer(rsdata.getInt(3)));
if(!rs.next())
{
innerloop=false;
loop=false;
break;
}
if(!rs.getString(1).equals(chggrp))
innerloop=false;
chggrp=rs.getString(1);
}
for(int s=0; s < success.size(); s++  ){
 
int h = ((Integer)hightlight.get(s)).intValue();
if(h==1)
out.print("<td style='background-color:#E33740'>"+success.get(s)+"%</span></td>")  ;
else
out.print("<td>"+success.get(s)+"%</td>")  ;
}
out.print("<td>"+87+"</td>");
%>
<td></td>
</tr>
<tr>
<td>volume </td>
 
<% for(int v=0; v < volume.size(); v++  ){
 
out.print("<td>"+volume.get(v)+"</td>")  ;
}
 
volume=null;
success=null;
 
}
 
//System.out.println(mdata);
conn.close();
rs.close();
rsdata.close();
pstmt.close();
pstmtdata.close();
}
catch(Exception e){
 
e.printStackTrace();
conn=null;
 
}
}
 
%>
 
</table>
</body>
</html> 

Open in new window

Sir,
       Its giving error on line 126 in the above code. Stating insert finally to complete TryStatement. if I am taking this } off then chggrp cannot be resolved :(
It was correct is saying that it cant resolve the chggrp because I had it declared inside a if condition..
local declaration  is valid only for the scope (i.e. inside {} only)..
use the code below, it should atleast compile.. I am not sure of the output as of yet.
<%@ page import="java.text.DateFormat,java.text.SimpleDateFormat,java.util.*,java.sql.*" %>
<html>
<body>
<%
SimpleDateFormat df = new SimpleDateFormat("EEE - MMM d, yyyy");
Calendar origDay = Calendar.getInstance();
Calendar prevDay = (Calendar) origDay.clone();
prevDay.add (Calendar.DAY_OF_YEAR, -1);
%>
 
<%! public ArrayList getDays(){
 
ArrayList dateList = new ArrayList();
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
 
Calendar cal =  Calendar.getInstance();
dateFormat.format(cal.getTime());
 
for(int i =0; i <=6; i++)
{
cal.add(Calendar.DATE, -1);
dateList.add(dateFormat.format(cal.getTime()));
 
}
return dateList;
}
%>
<%
java.util.ArrayList days= getDays();
%>
<h5><b>Current Status as of <%= df.format(prevDay.getTime()) %></b></h5>
<table border="1" cellspacing="1" bgcolor="#FFFFFF" WIDTH=99%>
<tr>
<th><b>Channel Group</b></th>
<th><b> Metric </b></th>
<% for( int i=0; i<days.size(); i++){%>
<th ><%=days.get(i)%></th>
<%}%>
<th><b>Minimum SLA </b></th>
</tr>
<%
Connection conn= null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@sd.xyz.com:T02","user", "pass");
 
String sql= "",sqldata="" ;
PreparedStatement pstmt= null,pstmtdata=null;
ResultSet rs = null , rsdata=null;
 
 
try{
sql ="SELECT CHANNELGROUP, SUCCESS_RATE, VOLUME, NVL(TO_CHAR(d, 'mm/dd/yyyy'), ' ') EASTCOAST_DATE from  VSLAND.APM_WEB_QKPAY_METRICPAGE_V, (SELECT TRUNC(SYSDATE) - LEVEL + 1 d FROM DUAL CONNECT BY LEVEL <= 7) WHERE  EASTCOAST_DATE(+) = d ORDER BY CHANNELGROUP, d DESC"; 
pstmt= conn.prepareStatement(sql);
rs= pstmt.executeQuery(sql);
ArrayList success = new ArrayList();
ArrayList volume  =  new ArrayList();
ArrayList hightlight  =  new ArrayList();
String chggrp;
if(rs.next()){
chggrp =rs.getString(1);
}
boolean loop=true;
while(loop){
boolean innerloop=true;
%>
<tr>
<th rowspan=2 ><%=chggrp%></th>
<td> success </td>
<%
while(innerloop)
{
	float f = rs.getFloat(2);
if( f < 87 )
	hightlight.add(new Integer(1)); // true
else
	hightlight.add(new Integer(0)); // false
success.add(new Float(f)) ;
volume.add( new Integer(rsdata.getInt(3)));
if(!rs.next())
{
innerloop=false;
loop=false;
break;
}
if(!rs.getString(1).equals(chggrp))
innerloop=false;
chggrp=rs.getString(1);
}
for(int s=0; s < success.size(); s++  ){
 
int h = ((Integer)hightlight.get(s)).intValue();
if(h==1)
out.print("<td style='background-color:#E33740'>"+success.get(s)+"%</span></td>")  ;
else
out.print("<td>"+success.get(s)+"%</td>")  ;
}
out.print("<td>"+87+"</td>");
%>
<td></td>
</tr>
<tr>
<td>volume </td>
 
<% for(int v=0; v < volume.size(); v++  ){
 
out.print("<td>"+volume.get(v)+"</td>")  ;
}
 
volume=null;
success=null;
 
}
 
//System.out.println(mdata);
conn.close();
rs.close();
rsdata.close();
pstmt.close();
pstmtdata.close();
}
catch(Exception e){
 
e.printStackTrace();
conn=null;
 
}
 
%>
 
</table>
</body>
</html> 

Open in new window

Sir,
     Code got compiled. It complained for the chggrp at two spots again that its not being initialized, so I just made it String chggrp="";
I got null pointer exception this time.
and output is attached.
 

[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R java.lang.NullPointerException
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm._jsp._test._jspService(_test.java:149)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
[1/5/09 15:02:04:234 CST] 00000028 SystemErr     R 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)

Open in new window

snap2.JPG
Hmm, if you run this query directly to the database, what result it produces?
In the meanwhile I will try to see why its giving a null pointer...
Since I am dry debugging ( i.e. not running the code but trying to debug by just looking at it, it will take some tries to get it right...
it is giving the sev days of data Sir. But how do we put that data in the desired format.
Attached is the snap shot of running query in sql developer

snap3.JPG
okay that data looks good.. lets do some system.outs to see what we are getting in our arrays..

It will be printing those statements on the console output..
let me know what its printing.
<%@ page import="java.text.DateFormat,java.text.SimpleDateFormat,java.util.*,java.sql.*" %>
<html>
<body>
<%
SimpleDateFormat df = new SimpleDateFormat("EEE - MMM d, yyyy");
Calendar origDay = Calendar.getInstance();
Calendar prevDay = (Calendar) origDay.clone();
prevDay.add (Calendar.DAY_OF_YEAR, -1);
%>
 
<%! public ArrayList getDays(){
 
ArrayList dateList = new ArrayList();
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
 
Calendar cal =  Calendar.getInstance();
dateFormat.format(cal.getTime());
 
for(int i =0; i <=6; i++)
{
cal.add(Calendar.DATE, -1);
dateList.add(dateFormat.format(cal.getTime()));
 
}
return dateList;
}
%>
<%
java.util.ArrayList days= getDays();
%>
<h5><b>Current Status as of <%= df.format(prevDay.getTime()) %></b></h5>
<table border="1" cellspacing="1" bgcolor="#FFFFFF" WIDTH=99%>
<tr>
<th><b>Channel Group</b></th>
<th><b> Metric </b></th>
<% for( int i=0; i<days.size(); i++){%>
<th ><%=days.get(i)%></th>
<%}%>
<th><b>Minimum SLA </b></th>
</tr>
<%
Connection conn= null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@sd.xyz.com:T02","user", "pass");
 
String sql= "",sqldata="" ;
PreparedStatement pstmt= null,pstmtdata=null;
ResultSet rs = null , rsdata=null;
 
 
try{
sql ="SELECT CHANNELGROUP, SUCCESS_RATE, VOLUME, NVL(TO_CHAR(d, 'mm/dd/yyyy'), ' ') EASTCOAST_DATE from  VSLAND.APM_WEB_QKPAY_METRICPAGE_V, (SELECT TRUNC(SYSDATE) - LEVEL + 1 d FROM DUAL CONNECT BY LEVEL <= 7) WHERE  EASTCOAST_DATE(+) = d ORDER BY CHANNELGROUP, d DESC"; 
pstmt= conn.prepareStatement(sql);
rs= pstmt.executeQuery(sql);
ArrayList success = new ArrayList();
ArrayList volume  =  new ArrayList();
ArrayList hightlight  =  new ArrayList();
String chggrp="";
if(rs.next()){
chggrp =rs.getString(1);
}
boolean loop=true;
while(loop){
boolean innerloop=true;
%>
<tr>
<th rowspan=2 ><%=chggrp%></th>
<td> success </td>
<%
while(innerloop)
{
	float f = rs.getFloat(2);
	System.out.println("Got the float"+f);
if( f < 87 )
	hightlight.add(new Integer(1)); // true
else
	hightlight.add(new Integer(0)); // false
success.add(new Float(f)) ;
volume.add( new Integer(rsdata.getInt(3)));
System.out.println("Volume was"+rsdata.getInt(3));
if(!rs.next())
{
innerloop=false;
loop=false;
break;
}
if(!rs.getString(1).equals(chggrp))
innerloop=false;
chggrp=rs.getString(1);
}
System.out.println("Success have"+success.size()+"elements");
for(int s=0; s < success.size(); s++  ){
 
int h = ((Integer)hightlight.get(s)).intValue();
if(h==1)
out.print("<td style='background-color:#E33740'>"+success.get(s)+"%</span></td>")  ;
else
out.print("<td>"+success.get(s)+"%</td>")  ;
}
out.print("<td>"+87+"</td>");
%>
<td></td>
</tr>
<tr>
<td>volume </td>
 
<% for(int v=0; v < volume.size(); v++  ){
 
out.print("<td>"+volume.get(v)+"</td>")  ;
}
 
volume=null;
success=null;
rs.next(); 
}
 
//System.out.println(mdata);
conn.close();
rs.close();
rsdata.close();
pstmt.close();
pstmtdata.close();
}
catch(Exception e){
 
e.printStackTrace();
conn=null;
 
}
 
%>
 
</table>
</body>
</html> 

Open in new window

Sir,
      Same output on JSP. and I have attached the console output

[1/5/09 15:38:12:381 CST] 0000003b SystemOut     O Got the float99.38
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R java.lang.NullPointerException
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm._jsp._test._jspService(_test.java:150)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
[1/5/09 15:38:12:381 CST] 0000003b SystemErr     R 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)

Open in new window

okay so we are reaching to the float atleast.. but after that its failing.. lets add some more system outs and see.

while(innerloop)
{
      float f = rs.getFloat(2);
      System.out.println("Got the float"+f); //we are reaching to this point.
if( f < 87 )
      hightlight.add(new Integer(1)); // true
else
      hightlight.add(new Integer(0)); // false
success.add(new Float(f)) ;
System.out.println("able to add the float"+f); // add this line as well
volume.add( new Integer(rsdata.getInt(3)));
System.out.println("Volume was"+rsdata.getInt(3));
if(!rs.next())
{
innerloop=false;
loop=false;
break;
}
I guess even this step is working :)

[1/5/09 15:49:05:425 CST] 0000003b SystemOut     O Got the float99.38
[1/5/09 15:49:05:425 CST] 0000003b SystemOut     O able to add the float99.38
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R java.lang.NullPointerException
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm._jsp._test._jspService(_test.java:151)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
[1/5/09 15:49:05:425 CST] 0000003b SystemErr     R 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)

Open in new window

which means our next step is not working where we are taking the Integer out on rs.getInt(3).

change following lines
volume.add( new Integer(rsdata.getInt(3)));
System.out.println("Volume was"+rsdata.getInt(3));
to
volume.add( new Integer(rsdata.getString(3)));
System.out.println("Volume was"+rsdata.getString(3));

just want to see if this third column is being accessed or not.
I got out of the office Sir. Will do first thing in the morning. Please stay with me.
Need your guidance on few other topics too
Avatar of Manish
Generally it is not good practice to make connections in JSP.
Use java classes to do make connection, get results.
Set this result in bean and read this bean in JSP and print result.
Hi Karan,
             I am very new to all this. could you please tell me how to do that? Can I make you use of that connection anywhere in my application?
@ Kuldeep Sir,
               Sir made the modification.
 

[1/6/09 8:29:59:734 CST] 00000023 SystemOut     O Got the float99.37
[1/6/09 8:29:59:734 CST] 00000023 SystemOut     O able to add the float99.37
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R java.lang.NullPointerException
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm._jsp._test._jspService(_test.java:151)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.handleRequest(AbstractJSPExtensionProcessor.java:270)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
[1/6/09 8:29:59:734 CST] 00000023 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)

Open in new window

Okay so this means we are able to get the float. but having an error at volume..
now this error can be at the volume itself, or at the point where you are adding it to the arraylist..
to eliminate it lets try to put the system.out BEFORE we add it to the array list.. this way we can determine whether its the data or something in our code when we are making an Integer out of it.


System.out.println("Volume is before being added"+rsdata.getString(3));
volume.add( new Integer(rsdata.getString(3)));

if(!rs.next())
{
innerloop=false;
loop=false;
break;
}
Did that Sir. Still the same
 

[1/6/09 8:39:16:654 CST] 00000023 SystemOut     O Got the float99.37
[1/6/09 8:39:16:654 CST] 00000023 SystemOut     O able to add the float99.37
[1/6/09 8:39:16:654 CST] 00000023 SystemErr     R java.lang.NullPointerException
[1/6/09 8:39:16:654 CST] 00000023 SystemErr     R 	at com.ibm._jsp._test._jspService(_test.java:152)
[1/6/09 8:39:16:654 CST] 00000023 SystemErr     R 	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[1/6/09 8:39:16:654 CST] 00000023 SystemErr     R 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[1/6/09 8:39:16:654 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(Servl

Open in new window

okay I am the biggest fool on planet expert-exchange....!!!

If I used "rs" to get the result... why am I trying to extract it from "rsdata"..!!!!!!!!


change following lines & let me know what happens..

volume.add( new Integer(rsdata.getInt(3)));
System.out.println("Volume was"+rsdata.getInt(3));
if(!rs.next())

to

volume.add( new Integer(rs.getInt(3)));
System.out.println("Volume was"+rs.getInt(3));
if(!rs.next())
Sir, you are helping me. Dont call yourself something like that... but u made me laugh :)
so we got little success. able to produce one row. snap shot and console output attached

[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Got the float99.37
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O able to add the float99.37
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Volume was112801
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Got the float99.38
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O able to add the float99.38
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Volume was98791
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Got the float99.31
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O able to add the float99.31
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Volume was93585
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Got the float99.46
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O able to add the float99.46
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Volume was109323
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Got the float99.35
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O able to add the float99.35
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Volume was130905
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Got the float99.38
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O able to add the float99.38
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Volume was108004
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Success have6elements
[1/6/09 9:01:46:892 CST] 00000024 SystemOut     O Got the float82.93
[1/6/09 9:01:46:892 CST] 00000024 SystemErr     R java.lang.NullPointerException
[1/6/09 9:01:46:908 CST] 00000024 SystemErr     R 	at com.ibm._jsp._test._jspService(_test.java:149)
[1/6/09 9:01:46:908 CST] 00000024 SystemErr     R 	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[1/6/09 9:01:46:908 CST] 00000024 SystemErr     R 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[1/6/09 9:01:46:908 CST] 00000024 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
[1/6/09 9:01:46:908 CST] 00000024 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[1/6/09 9:01:46:908 CST] 00000024 SystemErr     R 	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[1/6/09 9:01:46:908 CST] 00000024 SystemErr     R 	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)

Open in new window

met-snap.JPG
can you paste the current running code...
If we were able to run the first loop, we shd be able to run next cycle as well.. we need to see if I am referencing anything wrong or setting something to null which I shd not...
Sure...
<%@ page import="java.text.DateFormat,java.text.SimpleDateFormat,java.util.*,java.sql.*" %>
<html>
<body>
<%
SimpleDateFormat df = new SimpleDateFormat("EEE - MMM d, yyyy");
Calendar origDay = Calendar.getInstance();
Calendar prevDay = (Calendar) origDay.clone();
prevDay.add (Calendar.DAY_OF_YEAR, -1);
%>
 
<%! public ArrayList getDays(){
 
ArrayList dateList = new ArrayList();
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
 
Calendar cal =  Calendar.getInstance();
dateFormat.format(cal.getTime());
 
for(int i =0; i <=6; i++)
{
cal.add(Calendar.DATE, -1);
dateList.add(dateFormat.format(cal.getTime()));
 
}
return dateList;
}
%>
<%
java.util.ArrayList days= getDays();
%>
<h5><b>Current Status as of <%= df.format(prevDay.getTime()) %></b></h5>
<table border="1" cellspacing="1" bgcolor="#FFFFFF" WIDTH=99%>
<tr>
<th><b>Channel Group</b></th>
<th><b> Metric </b></th>
<% for( int i=0; i<days.size(); i++){%>
<th ><%=days.get(i)%></th>
<%}%>
<th><b>Minimum SLA </b></th>
</tr>
<%
Connection conn= null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@","user","pass");
 
String sql= "",sqldata="" ;
PreparedStatement pstmt= null,pstmtdata=null;
ResultSet rs = null , rsdata=null;
 
 
try{
sql ="SELECT CHANNELGROUP, SUCCESS_RATE, VOLUME, NVL(TO_CHAR(d, 'mm/dd/yyyy'), ' ') EASTCOAST_DATE from  VSLAND.APM_WEB_QKPAY_METRICPAGE_V, (SELECT TRUNC(SYSDATE) - LEVEL + 1 d FROM DUAL CONNECT BY LEVEL <= 7) WHERE  EASTCOAST_DATE(+) = d ORDER BY CHANNELGROUP, d DESC"; 
pstmt= conn.prepareStatement(sql);
rs= pstmt.executeQuery(sql);
ArrayList success = new ArrayList();
ArrayList volume  =  new ArrayList();
ArrayList hightlight  =  new ArrayList();
String chggrp="";
if(rs.next()){
chggrp =rs.getString(1);
}
boolean loop=true;
while(loop){
boolean innerloop=true;
%>
<tr>
<th rowspan=2 ><%=chggrp%></th>
<td> success </td>
<%
while(innerloop)
{
	float f = rs.getFloat(2);
	System.out.println("Got the float"+f);
if( f < 87 )
	hightlight.add(new Integer(1)); // true
else
	hightlight.add(new Integer(0)); // false
success.add(new Float(f)) ;
System.out.println("able to add the float"+f); // add this line as well
 
//System.out.println("Volume is before being added"+rsdata.getString(3));
volume.add( new Integer(rs.getInt(3)));
System.out.println("Volume was"+rs.getInt(3));
if(!rs.next())
{
innerloop=false;
loop=false;
break;
}
if(!rs.getString(1).equals(chggrp))
innerloop=false;
chggrp=rs.getString(1);
}
System.out.println("Success have"+success.size()+"elements");
for(int s=0; s < success.size(); s++  ){
 
int h = ((Integer)hightlight.get(s)).intValue();
if(h==1)
out.print("<td style='background-color:#E33740'>"+success.get(s)+"%</span></td>")  ;
else
out.print("<td>"+success.get(s)+"%</td>")  ;
}
out.print("<td>"+87+"</td>");
%>
<td></td>
</tr>
<tr>
<td>volume </td>
 
<% for(int v=0; v < volume.size(); v++  ){
 
out.print("<td>"+volume.get(v)+"</td>")  ;
}
 
volume=null;
success=null;
rs.next(); 
}
 
//System.out.println(mdata);
conn.close();
rs.close();
rsdata.close();
pstmt.close();
pstmtdata.close();
}
catch(Exception e){
 
e.printStackTrace();
conn=null;
 
}
 
%>
 
</table>
</body>
</html> 
 

Open in new window

okay I think I got it..


change these lines

volume=null;
success=null;

to

volume.clear();
success.clear();
hightlight.clear();
Wow :)
You are the Champ. But one last problem. or I can say two.
This happened to me last time as well, not all the channel group members have data for all the dates, so with the previous code we were submitting zero's on those dates. In our code, the date is getting over laped to the next position.

NEW-SNAP.JPG
Hmm... One quick & dirty way will be to prefill your arraylist with zeros or something it length is less than 7 for our arraylists...
something like following...

Its a crappy way of doing it, but for now my main focus is to get the code running, we can work on making it pretty later on.


<%@ page import="java.text.DateFormat,java.text.SimpleDateFormat,java.util.*,java.sql.*" %>
<html>
<body>
<%
SimpleDateFormat df = new SimpleDateFormat("EEE - MMM d, yyyy");
Calendar origDay = Calendar.getInstance();
Calendar prevDay = (Calendar) origDay.clone();
prevDay.add (Calendar.DAY_OF_YEAR, -1);
%>
 
<%! public ArrayList getDays(){
 
ArrayList dateList = new ArrayList();
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
 
Calendar cal =  Calendar.getInstance();
dateFormat.format(cal.getTime());
 
for(int i =0; i <=6; i++)
{
cal.add(Calendar.DATE, -1);
dateList.add(dateFormat.format(cal.getTime()));
 
}
return dateList;
}
%>
<%! public ArrayList padZeros(ArrayList a, int count){
for(int i=0;i<count;i++)
a.add(new Integer(0));
return a;
}
<%
java.util.ArrayList days= getDays();
%>
<h5><b>Current Status as of <%= df.format(prevDay.getTime()) %></b></h5>
<table border="1" cellspacing="1" bgcolor="#FFFFFF" WIDTH=99%>
<tr>
<th><b>Channel Group</b></th>
<th><b> Metric </b></th>
<% for( int i=0; i<days.size(); i++){%>
<th ><%=days.get(i)%></th>
<%}%>
<th><b>Minimum SLA </b></th>
</tr>
<%
Connection conn= null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@","user","pass");
 
String sql= "",sqldata="" ;
PreparedStatement pstmt= null,pstmtdata=null;
ResultSet rs = null , rsdata=null;
 
 
try{
sql ="SELECT CHANNELGROUP, SUCCESS_RATE, VOLUME, NVL(TO_CHAR(d, 'mm/dd/yyyy'), ' ') EASTCOAST_DATE from  VSLAND.APM_WEB_QKPAY_METRICPAGE_V, (SELECT TRUNC(SYSDATE) - LEVEL + 1 d FROM DUAL CONNECT BY LEVEL <= 7) WHERE  EASTCOAST_DATE(+) = d ORDER BY CHANNELGROUP, d DESC"; 
pstmt= conn.prepareStatement(sql);
rs= pstmt.executeQuery(sql);
ArrayList success = new ArrayList();
ArrayList volume  =  new ArrayList();
ArrayList hightlight  =  new ArrayList();
String chggrp="";
if(rs.next()){
chggrp =rs.getString(1);
}
boolean loop=true;
while(loop){
boolean innerloop=true;
%>
<tr>
<th rowspan=2 ><%=chggrp%></th>
<td> success </td>
<%
while(innerloop)
{
	float f = rs.getFloat(2);
	System.out.println("Got the float"+f);
if( f < 87 )
	hightlight.add(new Integer(1)); // true
else
	hightlight.add(new Integer(0)); // false
success.add(new Float(f)) ;
System.out.println("able to add the float"+f); // add this line as well
 
//System.out.println("Volume is before being added"+rsdata.getString(3));
volume.add( new Integer(rs.getInt(3)));
System.out.println("Volume was"+rs.getInt(3));
if(!rs.next())
{
innerloop=false;
loop=false;
break;
}
if(!rs.getString(1).equals(chggrp))
innerloop=false;
chggrp=rs.getString(1);
}
System.out.println("Success have"+success.size()+"elements");
success=padZeros(success,7-success.size());
highlight=padZeros(highlight,7-highlight.size());
volume=padZeros(volume,7-volume.size());
for(int s=0; s < success.size(); s++  ){
int h = ((Integer)hightlight.get(s)).intValue();
if(h==1)
out.print("<td style='background-color:#E33740'>"+success.get(s)+"%</span></td>")  ;
else
out.print("<td>"+success.get(s)+"%</td>")  ;
}
out.print("<td>"+87+"</td>");
%>
<td></td>
</tr>
<tr>
<td>volume </td>
 
<% for(int v=0; v < volume.size(); v++  ){
 
out.print("<td>"+volume.get(v)+"</td>")  ;
}
 
volume.clear();
success.clear();
hightlight.clear();
rs.next(); 
}
 
//System.out.println(mdata);
conn.close();
rs.close();
rsdata.close();
pstmt.close();
pstmtdata.close();
}
catch(Exception e){
 
e.printStackTrace();
conn=null;
 
}
 
%>
 
</table>
</body>
</html> 
 

Open in new window

Sir,
     I got this error:
/jsp/test.jsp(33,1) JSPG0060E: Invalid jsp syntax [ public ArrayList padZeros(ArrayList a, int count){
for(int i=0;i<count;i++)
a.add(new Integer(0));
return a;
}
]
 
 Then following query was filling zeros whenever thr is no data present.

select SUCCESS_RATE , VOLUME, NVL(to_char(D, 'mm/dd/yyyy'),' ') EASTCOAST_DATE from VSLAND.APM_WEB_QKPAY_METRICPAGE_V, ( SELECT TRUNC(SYSDATE) - LEVEL + 1 D FROM DUAL CONNECT BY LEVEL <=7) where CHANNELGROUP(+) ='"+rs.getString(1)+"' and EASTCOAST_DATE(+) = D order by D desc
 
Sir I changed the order of the dates. so new code and output is attached  AND THE CONSOLE OUTPUT IS: also attached. its still complaining for null pointer
 
 

<%@ page import="java.text.DateFormat,java.text.SimpleDateFormat,java.util.*,java.sql.*" %>
<html>
<body>
<%
SimpleDateFormat df = new SimpleDateFormat("EEE - MMM d, yyyy");
Calendar origDay = Calendar.getInstance();
Calendar prevDay = (Calendar) origDay.clone();
prevDay.add (Calendar.DAY_OF_YEAR, -1);
%>
 
<%! public ArrayList getDays(){
 
ArrayList dateList = new ArrayList();
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
 
Calendar cal =  Calendar.getInstance();
dateFormat.format(cal.getTime());
 
for(int i =0; i <=6; i++)
{
cal.add(Calendar.DATE, -1);
dateList.add(dateFormat.format(cal.getTime()));
 
}
return dateList;
}
%>
 
 
 
<%
java.util.ArrayList days= getDays();
 
java.util.Collections.reverse(days);
%>
<h5><b>Current Status as of <%= df.format(prevDay.getTime()) %></b></h5>
<table border="1" cellspacing="1" bgcolor="#FFFFFF" WIDTH=99%>
<tr>
<th><b>Channel Group</b></th>
<th><b> Metric </b></th>
<% for( int i=0; i<days.size(); i++){%>
<th ><%=days.get(i)%></th>
<%}%>
<th><b>Minimum SLA </b></th>
</tr>
<%
Connection conn= null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@ml");
 
String sql= "",sqldata="" ;
PreparedStatement pstmt= null,pstmtdata=null;
ResultSet rs = null , rsdata=null;
 
 
try{
sql ="SELECT CHANNELGROUP, SUCCESS_RATE, VOLUME, NVL(TO_CHAR(d, 'mm/dd/yyyy'), ' ') EASTCOAST_DATE from  VSLAND.APM_WEB_QKPAY_METRICPAGE_V, (SELECT TRUNC(SYSDATE - 1) - LEVEL + 1 d FROM DUAL CONNECT BY LEVEL <= 7) WHERE  EASTCOAST_DATE(+) = d ORDER BY CHANNELGROUP, d"; 
pstmt= conn.prepareStatement(sql);
rs= pstmt.executeQuery(sql);
ArrayList success = new ArrayList();
ArrayList volume  =  new ArrayList();
ArrayList hightlight  =  new ArrayList();
String chggrp="";
if(rs.next()){
chggrp =rs.getString(1);
}
boolean loop=true;
while(loop){
boolean innerloop=true;
%>
<tr>
<th rowspan=2 ><%=chggrp%></th>
<td> success </td>
<%
while(innerloop)
{
	float f = rs.getFloat(2);
	System.out.println("Got the float"+f);
if( f < 87 )
	hightlight.add(new Integer(1)); // true
else
	hightlight.add(new Integer(0)); // false
success.add(new Float(f)) ;
System.out.println("able to add the float"+f); // add this line as well
 
//System.out.println("Volume is before being added"+rsdata.getString(3));
volume.add( new Integer(rs.getInt(3)));
System.out.println("Volume was"+rs.getInt(3));
if(!rs.next())
{
innerloop=false;
loop=false;
break;
}
if(!rs.getString(1).equals(chggrp))
innerloop=false;
chggrp=rs.getString(1);
}
System.out.println("Success have"+success.size()+"elements");
for(int s=0; s < success.size(); s++  ){
 
int h = ((Integer)hightlight.get(s)).intValue();
if(h==1)
out.print("<td style='background-color:#E33740'>"+success.get(s)+"%</span></td>")  ;
else
out.print("<td>"+success.get(s)+"%</td>")  ;
}
out.print("<td>"+87+"</td>");
%>
<td></td>
</tr>
<tr>
<td>volume </td>
 
<% for(int v=0; v < volume.size(); v++  ){
 
out.print("<td>"+volume.get(v)+"</td>")  ;
}
 
volume.clear();
success.clear();
hightlight.clear();
rs.next(); 
}
 
//System.out.println(mdata);
conn.close();
rs.close();
rsdata.close();
pstmt.close();
pstmtdata.close();
}
catch(Exception e){
 
e.printStackTrace();
conn=null;
 
}
 
%>
 
</table>
</body>
</html> 
 

Open in new window

untitled.JPG
comsole.txt
in my previous code insert a %> at line number 32 AFTER "}"
I shd have closed the tag which I forgot as usual
got this:
Io exception: SO Exception was generated  
ASKER CERTIFIED SOLUTION
Avatar of Kuldeepchaturvedi
Kuldeepchaturvedi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes sir,
           The exact same code :(
Error 500: Io exception: SO Exception was generated  

[1/6/09 10:44:25:914 CST] 00000024 WebApp        E   [Servlet Error]-[/jsp/test.jsp]: java.sql.SQLException: Io exception: SO Exception was generated
	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
	at oracle.jdbc.ttc7.TTC7Protocol.handleIOException(TTC7Protocol.java:3695)
	at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:352)
	at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:362)
	at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:536)
	at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:328)
	at java.sql.DriverManager.getConnection(DriverManager.java:562)
	at java.sql.DriverManager.getConnection(DriverManager.java:186)
	at com.ibm._jsp._test._jspService(_test.java:122)
	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
	at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)

Open in new window

that is a Oracle exception...!!!

did you change anything in the connection property??

in previous posts the connection line was

conn=DriverManager.getConnection("jdbc:oracle:thin:@sd.xyz.com:T02","user", "pass");


now it is
conn = DriverManager.getConnection("jdbc:oracle:thin:@","user","pass");
 

& hence the exception...!
I dont know how it changed because I was just copying the code from this thread only..!!
oops. I am sorry.. acting like a fool here :)
so after changing it back it shd be working.
It worked. but data is not correct according to the dates.
For first row its perfect. not for others :(

<%@ page import="java.text.DateFormat,java.text.SimpleDateFormat,java.util.*,java.sql.*" %>
<html>
<body>
<%
SimpleDateFormat df = new SimpleDateFormat("EEE - MMM d, yyyy");
Calendar origDay = Calendar.getInstance();
Calendar prevDay = (Calendar) origDay.clone();
prevDay.add (Calendar.DAY_OF_YEAR, -1);
%>
 
<%! public ArrayList getDays(){
 
ArrayList dateList = new ArrayList();
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
 
Calendar cal =  Calendar.getInstance();
dateFormat.format(cal.getTime());
 
for(int i =0; i <=6; i++)
{
cal.add(Calendar.DATE, -1);
dateList.add(dateFormat.format(cal.getTime()));
 
}
return dateList;
}
%>
<%! public ArrayList padZeros(ArrayList a, int count){
for(int i=0;i<count;i++)
a.add(new Integer(0));
return a;
}%>
<%
java.util.ArrayList days= getDays();
java.util.Collections.reverse(days);
%>
<h5><b>Current Status as of <%= df.format(prevDay.getTime()) %></b></h5>
<table border="1" cellspacing="1" bgcolor="#FFFFFF" WIDTH=99%>
<tr>
<th><b>Channel Group</b></th>
<th><b> Metric </b></th>
<% for( int i=0; i<days.size(); i++){%>
<th ><%=days.get(i)%></th>
<%}%>
<th><b>Minimum SLA </b></th>
</tr>
<%
Connection conn= null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@mlpi148.sfdc.sbc.com:1522:osfd002","vsland", "mt_vsland");
 
String sql= "",sqldata="" ;
PreparedStatement pstmt= null,pstmtdata=null;
ResultSet rs = null , rsdata=null;
 
 
try{
sql ="SELECT CHANNELGROUP, SUCCESS_RATE, VOLUME, NVL(TO_CHAR(d, 'mm/dd/yyyy'), ' ') EASTCOAST_DATE from  VSLAND.APM_WEB_QKPAY_METRICPAGE_V, (SELECT TRUNC(SYSDATE - 1) - LEVEL + 1 d FROM DUAL CONNECT BY LEVEL <= 7) WHERE  EASTCOAST_DATE(+) = d ORDER BY CHANNELGROUP, d"; 
pstmt= conn.prepareStatement(sql);
rs= pstmt.executeQuery(sql);
ArrayList success = new ArrayList();
ArrayList volume  =  new ArrayList();
ArrayList hightlight  =  new ArrayList();
String chggrp="";
if(rs.next()){
chggrp =rs.getString(1);
}
boolean loop=true;
while(loop){
boolean innerloop=true;
%>
<tr>
<th rowspan=2 ><%=chggrp%></th>
<td> success </td>
<%
while(innerloop)
{
	float f = rs.getFloat(2);
	System.out.println("Got the float"+f);
if( f < 87 )
	hightlight.add(new Integer(1)); // true
else
	hightlight.add(new Integer(0)); // false
success.add(new Float(f)) ;
System.out.println("able to add the float"+f); // add this line as well
 
//System.out.println("Volume is before being added"+rsdata.getString(3));
volume.add( new Integer(rs.getInt(3)));
System.out.println("Volume was"+rs.getInt(3));
if(!rs.next())
{
innerloop=false;
loop=false;
break;
}
if(!rs.getString(1).equals(chggrp))
innerloop=false;
chggrp=rs.getString(1);
}
System.out.println("Success have"+success.size()+"elements");
success=padZeros(success,7-success.size());
hightlight=padZeros(hightlight,7-hightlight.size());
volume=padZeros(volume,7-volume.size());
for(int s=0; s < success.size(); s++  ){
int h = ((Integer)hightlight.get(s)).intValue();
if(h==1)
out.print("<td style='background-color:#E33740'>"+success.get(s)+"%</span></td>")  ;
else
out.print("<td>"+success.get(s)+"%</td>")  ;
}
out.print("<td>"+87+"</td>");
%>
<td></td>
</tr>
<tr>
<td>volume </td>
 
<% for(int v=0; v < volume.size(); v++  ){
 
out.print("<td>"+volume.get(v)+"</td>")  ;
}
 
volume.clear();
success.clear();
hightlight.clear();
rs.next(); 
}
 
//System.out.println(mdata);
conn.close();
rs.close();
rsdata.close();
pstmt.close();
pstmtdata.close();
}
catch(Exception e){
 
e.printStackTrace();
conn=null;
 
}
 
%>
 
</table>
</body>
</html> 
 
 

Open in new window

NEW-SNAP.JPG
query.JPG
Hmm we are skipping one row in the process.....

i know why..!!!!!!

At the very bottom of the page, I have one rs.next();
and thats what we dont need..!!

volume.clear();
success.clear();
hightlight.clear();
rs.next();

remove this last rs.next();

and then our loops shd be in order.

Wow... Thanks a ton sir. I wasted lot of your time :)
It worked perfectly. Could you please tell me what different we did in this code with the one I had originally and why did u say that submitting zeros this way is not a good technique
Now that it works..

If one my junior would have coded it, he/she would have gotten a 3.5/10 for this code...

here is why..

1. Making dbase connections inside the jsp page is not a good technique. It needs to be done via connection pooling--> java class --> jsp.
or atleast a java class and then jsp.

2. writing methods inside jsp page is highly discouraged.. you should use static java classes to write the methods there and then use them in jsp, this way you dont have to write them over & over again..

3. the original code that you had, had 2 loops, when you converted it to single query, the loops should have been converted too which you did not do originally hence this question came into light.

4.  If you needed the data in transposed fashion ( i.e. horizontal and not vertical) you should have designed the database accordingly.. I will still leave it because dbase may have been defined even before you came onboard.

5. Current code does not have a solid error controlling mechanism..

I am sure.. I will get better with your help :)
I am still getting the null pointer exception on console.
Sir I am posting a new question regarding the pool mechanism. could u please guide me to do that
post the console data.... I think in our code there is scope of a null pointer being thrown still

Thanks a ton sir :)
If I ever come to newYork I really owe you a big treat. :)
Tried to look you up on linkedIn :)


[1/6/09 11:31:59:943 CST] 00000032 SystemOut O Success have7elements
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R java.lang.NullPointerException
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm._jsp._test._jspService(_test.java:299)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
console data
[1/6/09 11:31:59:943 CST] 00000032 SystemOut     O Success have7elements
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R java.lang.NullPointerException
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm._jsp._test._jspService(_test.java:299)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
[1/6/09 11:31:59:974 CST] 00000032 SystemErr     R 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)

Open in new window

need full console..

i.e. from start to finish ( including all the added msgs etc..
Also tell me how many rows your query is fetching..
This is the complete console.
That table has around 2000 rows.

[1/6/09 12:06:38:566 CST] 00000022 FileRepositor A   ADMR0009I: Document cells/ILCDTD01AS3567BNode01Cell/applications/metdal.ear/deltas/metdal/delta-1231265198113 is created.
[1/6/09 12:06:38:628 CST] 00000022 FileRepositor A   ADMR0010I: Document cells/ILCDTD01AS3567BNode01Cell/applications/metdal.ear/deployments/metdal/deployment.xml is modified.
[1/6/09 12:06:54:920 CST] 00000023 ServletWrappe I   SRVE0242I: [metdal] [/apmQpay] [/jsp/test.jsp]: Initialization successful.
[1/6/09 12:06:57:872 CST] 00000023 SystemErr     R java.lang.NullPointerException
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm._jsp._test._jspService(_test.java:295)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.handleRequest(AbstractJSPExtensionProcessor.java:270)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
[1/6/09 12:06:57:888 CST] 00000023 SystemErr     R 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)

Open in new window

okay we need to remove

rsdata.close();

we are not using rsdata anymore so there is no point closing it either..
just delete it and it should take care of the null pointer.
Still coming :)
Should I close all the statement and resultset objects that we are not using?
yup whatever is not in use ( i.e. rsdata and pstmtdata ) needs to be removed from the code..
you still need one connection for your one query so that piece shd be left.
Ok sir I will do it.
Thanks for so much of help. If you get time then please look at my other qestion :)
is it in jsp area?
link?
I have some busy afternoon so I will have a look later though