Jump to content
Changes to the Jaspersoft community edition download ×

how to solve this problem with jaspereport&ireport


Recommended Posts

The followes is my source code


package test;


import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;


import net.sf.jasperreports.engine.JRDataSource;

import net.sf.jasperreports.engine.JRException;

import net.sf.jasperreports.engine.JasperReport;

import net.sf.jasperreports.engine.data.JRAbstractBeanDataSourceProvider;

import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;

public class ZdxxRepDatasource extends JRAbstractBeanDataSourceProvider{

private String zddmstring;


public String getZddmstring() {

return zddmstring;



public void setZddmstring(String zddmstring) {

this.zddmstring = zddmstring;



public ZdxxRepDatasource(String zddmstring) {


// TODO Auto-generated constructor stub



public JRDataSource create(JasperReport report) throws JRException{

ArrayList zdxxlist=new ArrayList();

String zddmstring=this.zddmstring;

ConnectDB conn=new ConnectDB();

String sql="select * from zdxxb where zddm='"+zddmstring+"'";

ResultSet rs=conn.executeQuery(sql);




zdxxlist.add(new ZdxxReport(rs.getString("zddm"),rs.getString("zdmc")));



catch(SQLException e)




return new JRBeanCollectionDataSource(zdxxlist);



public void dispose(JRDataSource arg0) throws JRException {

// TODO Auto-generated method stub






package test;


public class ZdxxReport {

String zddm;

String zdmc;

public ZdxxReport(String zddm, String zdmc) {


this.zddm = zddm;

this.zdmc = zdmc;


public ZdxxReport()


zddm = null;

zdmc = null;


public String getZddm() {

return zddm;


public void setZddm(String zddm) {

this.zddm = zddm;


public String getZdmc() {

return zdmc;


public void setZdmc(String zdmc) {

this.zdmc = zdmc;





while the ConnectDB.java is right

I edit it in eclipse and show they are right.

then i jar them with the package test and name the jar xx.jar and then look:

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