Jump to content

java swing / mysql / Jasper report - how to pass parameter?


Recommended Posts

I am doing a student project  using java swing/mysql and jasper reports.

I did the follwing:

1. created a mysql database dis

2. created JDBC connection.

3.created a report , farmer_details, using jaspersoft ireport designer.

4.connected the report using the following java swing code

using the following code i am getting the Jasper report(without passing parameters to sql query).


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
           JasperDesign jd=JRXmlLoader.load("/home/john/NetBeansProjects/dis/reports/farmer_details.jrxml");
           String sql="select * from farmers where farmer_id=1";
            JRDesignQuery newQuery= new JRDesignQuery();
            JasperReport jr=JasperCompileManager.compileReport(jd);
            JasperPrint jp=JasperFillManager.fillReport(jr, null, conn);
       }catch(Exception e){


5. I would like to pass farmer_id as a parameter to the Jasper report from Java swing in the above listed code.

please help me

john simon

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

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