Jump to content
Changes to the Jaspersoft community edition download ×

Recommended Posts

By: Danny Liu - dsyliu

Parameter

2003-06-27 13:20

Following is my java code:

 

JasperDesign design = JasperManager.loadXmlDesign( report.getXmlSourceWithFullPath() );

JasperReport jasperReport = JasperCompileManager.compileReport( design );

String sqlQuery = jasperReport.getQuery().getText();

Class.forName( "com.sybase.jdbc.SybDriver" );

Connection conn = DriverManager.getConnection( "jdbc:sybase:Tds:xxx.xxx.xxx.xxx", "sa", "sa" );

Map parameters = new HashMap();

for ( int j=0; j<paramList.size(); j++ )

{

parameters.put( ((JRDesignParameter)paramList.get(j)).getName(), ((JReportArgument)jReportArgumentList.get(j)).getPairValue() );

}

ResultSet rs = JRQueryExecuter.executeQuery(jasperReport.getQuery(),parameters,null,conn);

JRResultSetDataSource rsDataSource = new JRResultSetDataSource( rs );

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

 

 

and here is my query in XML file:

<parameter name="customer" isForPrompting="true" class="java.lang.Integer">

<defaultValueExpression><![CDATA[new Integer(527)]]></defaultValueExpression>

</parameter>

<queryString><![CDATA[select * from vehicle where customer_uk = $P{customer}]]></queryString>

 

 

I receive error on ResultSet rs = JRQueryExecuter.executeQuery(jasperReport.getQuery(),parameters,null,conn);

 

I already tried many different ways but none of them work. Can somebody please tell me what's wrong with my code? Also, I notice that this function takes in two parameters (HashTable), what's the difference? If one is parameter name, and the other one is value, then why do we need to use parameter.put(Name,Value)? Can somebody give me an example on how to do this?

 

Thank you

dsyliu

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