Jump to content

bokucrow

Members
  • Posts

    1
  • Joined

  • Last visited

bokucrow's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. Hello, I've written a scriptlet class that returns a simple SQL query as a string: package com.crow.Test;import net.sf.jasperreports.engine.JRDefaultScriptlet;import net.sf.jasperreports.engine.JRScriptletException;public class TestClass extends JRDefaultScriptlet { public String TestMethod() throws JRScriptletException { return "SELECT firstName FROM people LIMIT 10;"; }}[/code]This string is then incorporated into the SQL query of my .jrxml report. <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1 -->... <scriptlet name="Test" class="com.crow.Test.TestClass"> <scriptletDescription><![CDATA[]]></scriptletDescription> </scriptlet>... <queryString language="SQL"> <![CDATA[$P!{Test_SCRIPTLET}.TestMethod()]]> </queryString> <textField> <textElement textAlignment="Right" verticalAlignment="Middle"> <font size="12"/> </textElement> <textFieldExpression><![CDATA[$P{Test_SCRIPTLET}.TestMethod()]]></textFieldExpression> </textField>...[/code]However, the SQL (via $P!{Test_SCRIPTLET}.TestMethod()) fails with an exception of: I can confirm that the scriptlet is working as it should because its query is successfully displayed in a textbox if I suppress the query SQL or run the "One Empty Record" option. The exception only occurs if the SQL is issued to the DB. Everything I've read so far indicates this config should work -- have I missed something? Thanks in advance!
×
×
  • Create New...