Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8581395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:02:17+00:00 2026-06-11T21:02:17+00:00

I have a main report with a main query and a Table (with subdataset

  • 0

I have a main report with a main query and a Table (with subdataset) inside of it, which has its own Query.

I know how to specify the Query for the main report, but I don’t know how the to specify Query for the subdatset in my Java code of creation reports.

Can anyone help, please ?

My code:

public static java.sql.Connection cx = Connexion.SetConOn();

public static void Create report(String Query, String model, String title, String art) {
    try {
        JRDesignQuery jrd = new JRDesignQuery();
        JasperDesign design = JRXmlLoader.load(model);
        jrd.setText(Query);
        design.setQuery(jrd);
        Map map = new HashMap();
        JasperReport etat = JasperCompileManager.compileReport(design);
        JasperPrint print = JasperFillManager.fillReport(etat, map, cx);
        File f = new File("C:\\" + fdg);
        f.mkdir();
        JasperExportManager.exportReportToPdfFile(print, f.getPath() + "\\" + title + ".pdf");
        JasperViewer jv = new JasperViewer(print, false, Locale.FRENCH);

        try {
            java.awt.image.BufferedImage bi = javax.imageio.ImageIO.read(jv.getClass().getResource("/cycloplan/Images/Burn-icon1.png"));
            javax.swing.ImageIcon myImg = new javax.swing.ImageIcon(bi);
            jv.setIconImage(myImg.getImage());

        } catch (java.io.IOException ex) {
            ex.printStackTrace();
        }

        jv.setTitle(title);
        jv.setAlwaysOnTop(true);
        jv.setVisible(true);
    } catch (JRException ex) {
        ex.printStackTrace();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:02:18+00:00Added an answer on June 11, 2026 at 9:02 pm

    The JasperDesign class has a few different ways to access subdatasets; take a look at the javadoc [link]. I think the following code should work to set the subdataset query, where subQueryString is the query you want to use and datasetName is the name given to the subdataset element in the JRXML.

    JRDesignQuery subQuery = new JRDesignQuery();
    subQuery.setText(subQueryString);
    Map<String, JRDataset> datasetMap = design.getDatasetMap();
    JRDesignDataset subDataset = (JRDesignDataset) datasetMap.get(datasetName);
    subDataset.setQuery(subQuery);
    

    (* I haven’t actually tested this code. YMMV)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main report which loop over query's data on detail1 band. In
Hei, I have a main report with Portrait layout, but the main report contains
I have main window which has inner grid components. When I press a button
I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has
I have a main Report which consist of (Detail Report) Transaction # Amount Due
I have a database which has a table with an XML column. The XML
I have a Crystal Reports report in Visual Studio 2008 which has a subreport.
I have a main report that prompts the user to enter two parameters (@ORI
In VS 2008, I have a crystal main report with about 20 sub reports.
i have main activity in which i have Four menus. and i have one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.