Jump to content
Changes to the Jaspersoft community edition download ×

sending parameter not working


litium

Recommended Posts

this is a snippet of my java:

 

Code:
String startDate = request.getParameter("dateFrom"«»);
String endDate = request.getParameter("dateTo"«»);
System.out.println("start: " + startDate);
System.out.println("end: " + endDate);
Map parameters = new HashMap();
parameters.put("ReportTitle", "PDF JasperReport"«»);
parameters.put("StartDate", startDate);
parameters.put("EndDate", endDate);
InitialContext initialContext = new InitialContext();
DataSource ds = (DataSource)initialContext.lookup("java:comp/env/jdbc/StrutsSkeleton"«»);
Connection conn = ds.getConnection();
JasperPrint print = JasperFillManager.fillReport(report, parameters, conn);

 

and this is my jrxml code:

Code:
[code]<parameter name="StartDate" isForPrompting="false" class="java.lang.String"/>
<parameter name="EndDate" isForPrompting="false" class="java.lang.String"/>
<queryString><![CDATA[sELECT * FROM (SELECT a.*, ROWNUM rnum FROM (SELECT * FROM SALES_TRANSACTION WHERE VENDOR_ID LIKE '%' AND TRANS_DATE BETWEEN $P{StartDate} AND $P{EndDate} ORDER BY TRANS_TIMESTAMP DESC) a WHERE ROWNUM <= 30) WHERE rnum >= 1]]></queryString>

 

and i go this error when generating the report

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

 

anybody can help? thank you in advance.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi!

Can you give more than just the "message" of the exception?

You probably caught a nested exception, i.e., the top-level message does not give much information; you need the full stack trace, or at least all nested exception information ... e.printStackTrace() or such.

 

This should give you more information, e.g., whether your SQL query is welformed or not ... looks really strange to me, can't you just use a simple non-nested query? I've got no experience with ROWNUM, though.

 

On the other hand, AFAIR, JR also has a feature for setting the maximum number of returned rows.

 

Code:

SELECT * FROM SALES_TRANSACTION
WHERE VENDOR_ID LIKE '%' AND
TRANS_DATE BETWEEN $P{StartDate} AND $P{EndDate} AND
ROWNUM between 0 and 31
ORDER BY TRANS_TIMESTAMP DESC

 

Hope this helps,

Sebastian

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