Jump to content

How to coding to send the parameter into report?


SOYHU

Recommended Posts

How to coding to send the parameter into jrxml file ?

This is my code (// i want to send "SOYHU","SOYHU1","SOYHU2", ... variable parameter to jrxml file how about the coding syntax . )

 

/*

* Created on Nov 27, 2007

*

* TODO To change the template for this generated file go to

* Window - Preferences - Java - Code Style - Code Templates

*/

package net.ensode.jasperbook;

 

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import java.util.HashMap;

import java.util.Map;

 

import net.sf.jasperreports.engine.JasperFillManager;

 

/**

* @author admin

*

* TODO To change the template for this generated type comment go to

* Window - Preferences - Java - Code Style - Code Templates

*/

public class summary {

 

public static void main(String[] args) {

Connection conn= null;

Connection conn1= null;

try{

String host1 = "192.168.0.11";

String user1 = "administrator";

String password1 = "password";

String db1 = "SITBASE";

 

try {

Class.forName("com.ibm.db2.jcc.DB2Driver");

}

catch(java.lang.ClassNotFoundException e) {

System.err.print("ClassNotFoundException: ");

System.err.println(e.getMessage());

}

conn = DriverManager.getConnection("jdbc:db2://"+host+":50000/"+db , user,password);

conn1 = DriverManager.getConnection("jdbc:db2://"+host1+":50000/"+db1 , user1,password1); Statement stmt = conn1.createStatement();

String sql = "select oir.product_category,oir.product_type_II, oir.actual_payment_date ,oir.order_number ,oir.record_number ,uoi.user_id from user_order_item uoi inner join order_item_ref oir on uoi.record_number = oir.record_number where oir.record_number = 100000057";

 

ResultSet result =stmt.executeQuery(sql);

while (result.next()){

String SOYHU =result.getString(1) ;

String SOYHU1 =result.getString(2) ;

String SOYHU2 =result.getString(3) ;

String SOYHU3 =result.getString(4) ;

String SOYHU4 =result.getString(5) ;

String SOYHU5 =result.getString(6) ;

// i want to send "SOYHU","SOYHU1","SOYHU2", ... variable parameter to jrxml file how about the coding syntax .

 

}

System.out.println("Filling report...");

JasperFillManager.fillReportToFile("PC_Report_subreport1.jasper",

new HashMap(), conn1);

 

System.out.println("God bless you !");

}catch(Exception ex){

ex.printStackTrace();

}

finally{

if (conn != null){

try {

conn.close();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

 

 

}

}

}

 

please advise me.

Thank in advance.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

you pass the parameter in the HashMap:

 

SOYHU wrote:

How to coding to send the parameter into jrxml file ?
This is my code (// i want to send "SOYHU","SOYHU1","SOYHU2", ... variable parameter to jrxml file how about the coding syntax . )

/*
* Created on Nov 27, 2007
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package net.ensode.jasperbook;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;

import net.sf.jasperreports.engine.JasperFillManager;

/**
* @author admin
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class summary {

public static void main(String[] args) {
Connection conn= null;
Connection conn1= null;
try{
String host1 = "192.168.0.11";
String user1 = "administrator";
String password1 = "password";
String db1 = "SITBASE";

try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
}
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
conn = DriverManager.getConnection("jdbc:db2://"+host+":50000/"+db , user,password);
conn1 = DriverManager.getConnection("jdbc:db2://"+host1+":50000/"+db1 , user1,password1); Statement stmt = conn1.createStatement();
String sql = "select oir.product_category,oir.product_type_II, oir.actual_payment_date ,oir.order_number ,oir.record_number ,uoi.user_id from user_order_item uoi inner join order_item_ref oir on uoi.record_number = oir.record_number where oir.record_number = 100000057";

ResultSet result =stmt.executeQuery(sql);
while (result.next()){
String SOYHU =result.getString(1) ;
String SOYHU1 =result.getString(2) ;
String SOYHU2 =result.getString(3) ;
String SOYHU3 =result.getString(4) ;
String SOYHU4 =result.getString(5) ;
String SOYHU5 =result.getString(6) ;
// i want to send "SOYHU","SOYHU1","SOYHU2", ... variable parameter to jrxml file how about the coding syntax .

}
System.out.println("Filling report...");
JasperFillManager.fillReportToFile("PC_Report_subreport1.jasper",
new HashMap(), conn1);

System.out.println("God bless you !");
}catch(Exception ex){
ex.printStackTrace();
}
finally{
if (conn != null){
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();


}
}
}

please advise me.
Thank in advance.
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...