Link to home
Start Free TrialLog in
Avatar of aman0711
aman0711

asked on

Null pointer Exception

Hi experts,
                      I have the following code that displays the attached (snap shot) Table on my jsp page. This code works fine for  most of my backend tables. but today we are going to add another table and I am getting a null pointer exception when I try to run this code, though I am able to generate the table. The last Transactions data is what missing from the output.

       Can someone please help me out with it.
 
       I have attached the jsp output and output from Toad.
<table border="1" cellspacing="1" bgcolor="#FFFFFF" width=99%>
	<tr>
		<th><b>Transactions</b></th>
		<th align='center'><b> Metric </b></th>
		<%  
		        java.util.ArrayList days = dz.getDays();
                for (int i = 0; i < days.size(); i++) {
                %>
		<th align="center"><%=days.get(i)%></th>
		<%
                }
                %>
		<th align="center"><b>SLA </b></th>
	</tr>
	<%
                Connection conn = null;
                conn = db.getConnection();
 
                String sql = "";
                PreparedStatement pstmt = null;
                ResultSet rs = null;
 
                try {
 
                        ///////// NEW /////////
                        // CHANNELGROUP to SLAMIN lookup table
                        Hashtable slaMinList = new Hashtable();
                        sql = "SELECT METRIC, SLA_MIN FROM APM.APM_WEB_SLA_MIN WHERE APPLICATION='EPay'";
 
                        pstmt = conn.prepareStatement(sql);
                        rs = pstmt.executeQuery(sql);
                        while (rs.next()) {
                                String key = rs.getString(1);
                                float value = rs.getFloat(2);
                                slaMinList.put(key, new Float(value));
                        }
                        rs.close();
                        pstmt.close();
                        ///////// NEW /////////
 
                        sql = "SELECT EPAY_INSTANCE, SUCCESS_RATE, TOTAL_VOL, NVL(TO_CHAR(d, 'mm/dd/yyyy'), ' ') EVENT_DATE from  APM.APM_WEB_EPAY_METRICPAGE_V, (SELECT TRUNC(SYSDATE - 1) - LEVEL + 1 d FROM DUAL CONNECT BY LEVEL <= 7) WHERE EVENT_DATE(+) = d ORDER BY EPAY_INSTANCE, d";
                        pstmt = conn.prepareStatement(sql);
                        rs = pstmt.executeQuery(sql);
                        ArrayList success = new ArrayList();
                        ArrayList volume = new ArrayList();
                        ArrayList hightlight = new ArrayList();
                        float min = 0;
                        String chggrp = "";
                        if (rs.next()) {
                                chggrp = rs.getString(1);
                        }
                        boolean loop = true;
                        int rowcolor = 0; /// color code
						int daycount =0; //index for dates.
                        while (loop) {
                                boolean innerloop = true;
        %>
	<%
        if (rowcolor % 2 == 0) {
        %>
	<tr>
		<%
                } else {
                %>
	
	<tr style='background-color:#D0CECE'>
		<%
                }
                %>
 
		<th rowspan=2><%=chggrp%></th>
		<td align='center'><b>Volume</b></td>
		<%
                                        java.text.DecimalFormat nv = new java.text.DecimalFormat(
                                        "##,##,###");
                                        java.text.DecimalFormat np = new java.text.DecimalFormat(
                                        "#0.00%");
                                            
                                        while (innerloop) {
									String thisDate = rs.getString("EVENT_DATE");//get the record date								
                                while(!thisDate.equals(days.get(daycount)))
								{      //My dates dont match so we must be missing data, insert zeros
								success.add(new Float(1.0));
 
                                volume.add(new Integer(0));
			                                           	//also increase the day by one here
                                  daycount++;
                                 
								}
								float f = rs.getFloat(2);
								if (f==0.00 && rs.getInt(3)==0){
								f=1;
								}
 
                                ///////// NEW /////////
                                //                               if (f < 87)
                                Object ftemp = slaMinList.get(chggrp);
 
                                if (null != ftemp) {
                                        min = ((Float) ftemp).floatValue();
                                } else {
                                        min = 111;
                                }
 
                                if (f < min && min != 111)
                                        ///////// NEW /////////
                                        hightlight.add(new Integer(1)); // true
                                else
                                        hightlight.add(new Integer(0)); // false
                                success.add(new Float(f));
 
                                volume.add(new Integer(rs.getInt(3)));
 												daycount++;
                                if (!rs.next()) {
                                        innerloop = false;
                                        loop = false;
                                        break;
                                }
                                if (!rs.getString(1).equals(chggrp))
                                        innerloop = false;
                                chggrp = rs.getString(1);
                                        }
 
                                        success = dz.PadZeros(success, 7 - success.size(),1);
                                        hightlight = dz.PadZeros(hightlight, 7 - hightlight.size(),0);
                                        volume = dz.PadZeros(volume, 7 - volume.size(),0);
                                        for (int v = 0; v < volume.size(); v++) {
 
                                out.print("<td align='center'>" + nv.format(volume.get(v)) + "</td>");
                                        }
 
                                        ///////// NEW /////////
                                        out.print("<td align='center'>NA</td>");
                                        ///////// NEW /////////
                %>
	</tr>
	<%
        if (rowcolor % 2 == 0) { /// color code
        %>
	<tr>
 
		<%
                } else {
                %>
	
	<tr style='background-color:#D0CECE'>
		<%
                }
                %>
		<td align='center'><b>Success Rate</b></td>
 
		<%
                                for (int s = 0; s < success.size(); s++) {
                                int h = ((Integer) hightlight.get(s)).intValue();
                                if (h == 1)
                                        ///////// NEW /////////
                                        //                                        out.print("<td style='background-color:#E33740'>"
                                        out.print("<td align='center' style='background-color:#FF0000'>"
                                        ///////// NEW /////////
 
                                        + np.format(success.get(s))
                                        + "</span></td>");
                                else
                                        out.print("<td align='center'>" + np.format(success.get(s))
                                        + "</td>");
                                        }
                                        if (min != 111) {
                                out.print("<td align='center'>" + np.format(min) + "</td>");
                                        } else {
                                out.print("<td align='center'>NA</td>");
                                        }
                %>
	</tr>
	<%
                                volume.clear();
                                success.clear();
                                hightlight.clear();
								daycount=0;
                                rowcolor++;
                        }
 
                        conn.close();
                        rs.close();
                        pstmt.close();
 
                } catch (Exception e) {
 
                        e.printStackTrace();
                        conn = null;
 
                }
        %>
 
</table>

Open in new window

EP.PNG
DB-output.PNG
ASKER CERTIFIED SOLUTION
Avatar of mrjoltcola
mrjoltcola
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
SOLUTION
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
Avatar of aman0711
aman0711

ASKER

Hi mrjoltcola :)

             Thanks for responding. I guess its with the last application, where I have null data for the column EPAY_INSTANCE
Could be, but since we don't have the stack trace, we can only guess for you. Can you provide it?

Hmmm.. Could you tell me how to do that? I can post it within minutes
SOLUTION
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
ohk, Here is the console log:


4/6/09 17:42:01:537 CDT] 00000021 SystemOut     O Connection Details:com.ibm.ws.rsadapter.jdbc.WSJdbcConnection@28de28de
[4/6/09 17:42:04:772 CDT] 00000021 SystemErr     R java.lang.NullPointerException
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm._jsp._Transaction_5F_ep._jspService(_Transaction_5F_ep.java:324)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
[4/6/09 17:42:04:788 CDT] 00000021 SystemErr     R 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)

Open in new window

and I am using WAS 6.1
SOLUTION
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
hmm.. Ok I will try this now
SOLUTION
Avatar of Manish
Manish
Flag of India 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
Thanks :)