Jump to content
We've recently updated our Privacy Statement, available here ×

JRResultSetDataSource problem


Recommended Posts

By: Charles McClain - cmcclain1

JRResultSetDataSource problem

2003-04-19 07:24

I'm having difficulty passing a JRResultSetDataSource to my report and getting it to fill.

 

I create the JRResultSetDataSource in a bean, and store it as a session attribute, as follows:

 

String sql = new String("select CUST__T, CUST_NAME from CUSTOMER");

stmt = conn.prepareStatement(sql);

rs = stmt.executeQuery();

ds = new JRResultSetDataSource(rs);

session.setAttribute("QueryTestDataSource",ds);

 

.....and then try to use it in my JSP as follows:

 

JRResultSetDataSource ds = (JRResultSetDataSource) session.getAttribute("QueryTestDataSource");

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,ds);

 

I should note that I have a similar report which contains a SQL query, and a similar bean-JSP pair, which works flawlessly.

 

I have checked and double-checked my report definition file vs. my PreparedStatement, and both contain the same columns.

 

I also have debug writes to logs, and I can definitely see that the ResultSet from which Icreate the JRResultSetDataSource has about 30 rows. Also, I've written "ds" out to the log both in the bean and after I retrieve it from the HTTP session, and the signature is the same.

 

However, whatever I do, I get a "Unable to get next record" error when I run. What am I doing wrong?

 

 

 

 

By: Teodor Danciu - teodord

RE: JRResultSetDataSource problem

2003-04-21 01:58

 

Hi,

 

Can we see the entire exception stack trace,

not just the exception message?

 

Thank you,

Teodor

 

 

 

 

 

By: Charles McClain - cmcclain1

RE: JRResultSetDataSource problem

2003-04-21 04:46

Teodor:

 

Sure, although I'm not sure how helpful it will be -- not much info on the base exception, which was unhandled.

 

Since there doesn't seem to be a way to attach a file here, I guess I'll have to just copy it into this message; hope that is okay. Here goes:

 

Stack trace:

javax.servlet.ServletException: Unhandled exception caught in JSP service method: Unable to get next record.

at javax.servlet.ServletException.<init>(ServletException.java:107)

at pagecompile._RTS__HTML__Pages._customPages._QueryTest._en__US._html._pgQueryTestResponse_xjsp.performService(_pgQueryTestResponse_xjsp.java:190)

at com.rts.servlets.RTSBaseHttpServlet._jspService(RTSBaseHttpServlet.java:82)

at com.rts.servlets.RTSBaseHttpServlet.service(RTSBaseHttpServlet.java:1100)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.ibm.servlet.jsp.http.pagecompile.JSPState.service(JSPState.java:352)

at com.ibm.servlet.jsp.http.pagecompile.PageCompileServlet.doService(PageCompileServlet.java(Compiled Code))

at com.ibm.servlet.jsp.http.pagecompile.PageCompileServlet.doGet(PageCompileServlet.java:893)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:626)

at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:160)

at com.ibm.servlet.engine.webapp.ServicingServletState.service(StrictLifecycleServlet.java:307)

at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:105)

at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:360)

at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:775)

at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:701)

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:234)

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:138)

at com.rts.portal.servlets.JspRedirector.redirectLocalJsp(JspRedirector.java:1093)

at com.rts.portal.servlets.JspRedirector.redirectURL(JspRedirector.java:1251)

at com.rts.portal.servlets.JspRedirector.redirect(JspRedirector.java:982)

at com.rts.portal.servlets.JspRedirector.redirect(JspRedirector.java:944)

at com.rts.portal.servlets.JspRedirector.redirect(JspRedirector.java:891)

at com.rts.eAccess.framework.RequestHandler.sendPage(RequestHandler.java:3262)

at com.rts.eAccess.framework.RequestHandler.handleRequest(RequestHandler.java(Compiled Code))

at com.rts.eAccess.framework.RequestHandler.performService(RequestHandler.java:3019)

at com.rts.servlets.RTSBaseHttpServlet._jspService(RTSBaseHttpServlet.java:82)

at com.rts.servlets.RTSBaseHttpServlet.service(RTSBaseHttpServlet.java:1100)

at com.rts.eAccess.framework.RequestHandler.service(RequestHandler.java:3314)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:626)

at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:160)

at com.ibm.servlet.engine.webapp.ServicingServletState.service(StrictLifecycleServlet.java:307)

at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:105)

at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:360)

at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:775)

at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:701)

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:234)

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:138)

at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:77)

at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)

at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:106)

at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:160)

at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:300)

at com.ibm.servlet.engine.oselistener.SQEventListenerImp$ServiceRunnable.run(SQEventListenerImp.java:230)

at com.ibm.servlet.engine.oselistener.SQEventListenerImp.notifySQEvent(SQEventListenerImp.java:104)

at com.ibm.servlet.engine.oselistener.serverqueue.SQEventSource.notifyEvent(SQEventSource.java:212)

at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.notifyService(SQWrapperEventSource.java:353)

at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.run(SQWrapperEventSource.java:220)

at com.ibm.servlet.engine.oselistener.outofproc.OutOfProcThread$CtlRunnable.run(OutOfProcThread.java:248)

at java.lang.Thread.run(Thread.java:481)

 

29:26.48 EDT [Worker#12] [sEA1DP, 192.168.1.5] [RH.pgQueryTestResponse ] [ ] [pgQueryTestRes] handleServiceException(): Unhandled Exception: "javax.servlet.ServletException", Message: Unhandled exception caught in JSP service method: Unable to get next record.

Stack trace:

javax.servlet.ServletException: Unhandled exception caught in JSP service method: Unable to get next record.

at javax.servlet.ServletException.<init>(ServletException.java:107)

at pagecompile._RTS__HTML__Pages._customPages._QueryTest._en__US._html._pgQueryTestResponse_xjsp.performService(_pgQueryTestResponse_xjsp.java:190)

at com.rts.servlets.RTSBaseHttpServlet._jspService(RTSBaseHttpServlet.java:82)

at com.rts.servlets.RTSBaseHttpServlet.service(RTSBaseHttpServlet.java:1100)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.ibm.servlet.jsp.http.pagecompile.JSPState.service(JSPState.java:352)

at com.ibm.servlet.jsp.http.pagecompile.PageCompileServlet.doService(PageCompileServlet.java(Compiled Code))

at com.ibm.servlet.jsp.http.pagecompile.PageCompileServlet.doGet(PageCompileServlet.java:893)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:626)

at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:160)

at com.ibm.servlet.engine.webapp.ServicingServletState.service(StrictLifecycleServlet.java:307)

at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:105)

at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:360)

at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:775)

at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:701)

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:234)

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:138)

at com.rts.portal.servlets.JspRedirector.redirectLocalJsp(JspRedirector.java:1093)

at com.rts.portal.servlets.JspRedirector.redirectURL(JspRedirector.java:1251)

at com.rts.portal.servlets.JspRedirector.redirect(JspRedirector.java:982)

at com.rts.portal.servlets.JspRedirector.redirect(JspRedirector.java:944)

at com.rts.portal.servlets.JspRedirector.redirect(JspRedirector.java:891)

at com.rts.eAccess.framework.RequestHandler.sendPage(RequestHandler.java:3262)

at com.rts.eAccess.framework.RequestHandler.handleRequest(RequestHandler.java(Compiled Code))

at com.rts.eAccess.framework.RequestHandler.performService(RequestHandler.java:3019)

at com.rts.servlets.RTSBaseHttpServlet._jspService(RTSBaseHttpServlet.java:82)

at com.rts.servlets.RTSBaseHttpServlet.service(RTSBaseHttpServlet.java:1100)

at com.rts.eAccess.framework.RequestHandler.service(RequestHandler.java:3314)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:626)

at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:160)

at com.ibm.servlet.engine.webapp.ServicingServletState.service(StrictLifecycleServlet.java:307)

at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:105)

at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:360)

at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:775)

at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:701)

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:234)

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:138)

at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:77)

at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)

at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:106)

at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:160)

at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:300)

at com.ibm.servlet.engine.oselistener.SQEventListenerImp$ServiceRunnable.run(SQEventListenerImp.java:230)

at com.ibm.servlet.engine.oselistener.SQEventListenerImp.notifySQEvent(SQEventListenerImp.java:104)

at com.ibm.servlet.engine.oselistener.serverqueue.SQEventSource.notifyEvent(SQEventSource.java:212)

at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.notifyService(SQWrapperEventSource.java:353)

at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.run(SQWrapperEventSource.java:220)

at com.ibm.servlet.engine.oselistener.outofproc.OutOfProcThread$CtlRunnable.run(OutOfProcThread.java:248)

at java.lang.Thread.run(Thread.java:481)

 

29:26.48 EDT [Worker#12] [sEA1DP, 192.168.1.5] [RH.pgQueryTestResponse ] [fw ] [pgQueryTestRes] closing

29:26.97 EDT [Worker#12] [sEA1DP, 192.168.1.5] [RH ] [ ] [RH ] handleError: "com.rts.selfservice.SelfServiceException", Message: Failed to redirect() to the JSP customPages/QueryTest/en_US/html/pgQueryTestResponse.jsp

Stack trace:

Failed to redirect() to the JSP customPages/QueryTest/en_US/html/pgQueryTestResponse.jsp

Nested exception: "javax.servlet.ServletException"

Nested exception: "java.lang.NullPointerException"

Stack trace:

java.lang.NullPointerException

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:234)

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:138)

at com.rts.portal.servlets.JspRedirector.redirectLocalJsp(JspRedirector.java:1093)

at com.rts.portal.servlets.JspRedirector.redirectURL(JspRedirector.java:1251)

at com.rts.portal.servlets.JspRedirector.redirect(JspRedirector.java:982)

at com.rts.portal.servlets.JspRedirector.redirect(JspRedirector.java:944)

at com.rts.portal.servlets.JspRedirector.redirect(JspRedirector.java:891)

at com.rts.eAccess.framework.RequestHandler.sendPage(RequestHandler.java:3262)

at com.rts.eAccess.framework.RequestHandler.handleRequest(RequestHandler.java(Compiled Code))

at com.rts.eAccess.framework.RequestHandler.performService(RequestHandler.java:3019)

at com.rts.servlets.RTSBaseHttpServlet._jspService(RTSBaseHttpServlet.java:82)

at com.rts.servlets.RTSBaseHttpServlet.service(RTSBaseHttpServlet.java:1100)

at com.rts.eAccess.framework.RequestHandler.service(RequestHandler.java:3314)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:626)

at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:160)

at com.ibm.servlet.engine.webapp.ServicingServletState.service(StrictLifecycleServlet.java:307)

at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:105)

at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:360)

at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:775)

at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:701)

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:234)

at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:138)

at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:77)

at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)

at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:106)

at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:160)

at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:300)

at com.ibm.servlet.engine.oselistener.SQEventListenerImp$ServiceRunnable.run(SQEventListenerImp.java:230)

at com.ibm.servlet.engine.oselistener.SQEventListenerImp.notifySQEvent(SQEventListenerImp.java:104)

at com.ibm.servlet.engine.oselistener.serverqueue.SQEventSource.notifyEvent(SQEventSource.java:212)

at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.notifyService(SQWrapperEventSource.java:353)

at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.run(SQWrapperEventSource.java:220)

at com.ibm.servlet.engine.oselistener.outofproc.OutOfProcThread$CtlRunnable.run(OutOfProcThread.java:248)

at java.lang.Thread.run(Thread.java:481)

 

 

 

 

 

By: Teodor Danciu - teodord

RE: JRResultSetDataSource problem

2003-04-21 07:29

 

Hi,

 

I agree, it does not help.

Anyway, the only thing that could go wrong in

the JRResultSetDataSource, to produce this

exception is the call of the next() method on the

ResultSet object.

 

It would be helpful if you could catch the exception

so that we could see what is the SQLException

that occured when calling next().

 

Thank you,

Teodor

 

 

 

 

 

By: Charles McClain - cmcclain1

RE: JRResultSetDataSource problem

2003-05-17 13:13

Teodor:

 

I did as you suggested, trapping and displaying the SQL error message in my log.

 

The SQL error was "Closed result set". I did some reading up on SQL ResultSets, and discovered that the ResultSet gets closed when the PreparedStatement that creates it is closed (as you can guess, I'm not that familiar with ResultSets).

 

What I was trying to do was to execute the SQL query in a bean, stuff the ResultSet into an HTTP session variable, and then retrieve it in my JSP to create the JRResultSetDataSource.

 

Since my bean closed the PreparedStatement, of course the ResultSet was already closed when I retrieved it from the session variable.

 

I fixed it by putting the PreparedStatement in my JSP, and executing everything -- from the PreparedStatement to the FillManager call -- in one try-catch block before I close the PreparedStatement. It worked fine.

 

Although I'm not entirely happy with that solution, because it puts too much Java code in my JSP, at least I now know it works and will do what I need to do.

 

Now I can take my time and play around, looking for a more elegant approach. Thanks for the help.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...