Results 1 to 2 of 2
  1. #1
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Default how to set query to jasper via java code?

    how to set query to jasper via java code?

    Java Code:
    JasperDesign jasperDesign = JRXmlLoader.load("C:\\project\\learnjava\\myreport1.jrxml");
    
    JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
    
    Connection jdbcConn = connectMySQL();
    
    JasperPrint  jasperPrint = JasperFillManager.fillReport(jasperReport, null, jdbcConn);
    
    JasperViewer.viewReport(jasperPrint);

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    8

    Default

    Hi,

    From what I remembered if you don't want the query in the Jasper report template you can use the JasperFillManager.fillReport() method that accept the JRDataSource instead of the one that accept java.sql.Connection. Using JRDataSource you can inject the report data other than using a direct database query.

Similar Threads

  1. Replies: 9
    Last Post: 12-21-2010, 02:37 PM
  2. Mysql dynamic query, Java and Jasper report
    By rajuchacha007 in forum Advanced Java
    Replies: 5
    Last Post: 06-28-2010, 10:32 AM
  3. jasper report ,jasper report jar files and maven dependencies.
    By rajuchacha007 in forum Advanced Java
    Replies: 1
    Last Post: 04-09-2010, 08:15 AM
  4. Help with query (new to java!)
    By gpittingale in forum New To Java
    Replies: 3
    Last Post: 02-15-2009, 09:14 AM
  5. Jasper iReports and Java
    By shinky in forum New To Java
    Replies: 2
    Last Post: 08-09-2007, 09:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •