Jump to content
We've recently updated our Privacy Statement, available here ×

sumukha.prasanna

Members
  • Posts

    6
  • Joined

  • Last visited

sumukha.prasanna's Achievements

Rookie

Rookie (2/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. Hi All, I have a developed a Java console app which is connected to a datasource and generating a PDF from a .jrxml file(which was created using JasperStudio). Here is the program: public class JavaCallJasperReport { public static void main(String[] args) throws JRException, ClassNotFoundException, SQLException { String reportSrcFile = "C:/jasperreport/CustomerDataReport/CustomerData.jrxml"; JasperReport jasperReport = JasperCompileManager.compileReport(reportSrcFile); Connection conn = SQLServerConnUtils.getSQLServerConnection_SQLJDBC(); // Parameters for report Map<String, Object> parameters = new HashMap<>(); Connection conn = SQLServerConnUtils.getSQLServerConnection_SQLJDBC(); JasperPrint print = JasperFillManager.fillReport(jasperReport, parameters, conn); File outDir = new File("C:/jasperoutput"); outDir.mkdirs(); // PDF Exporter. JRPdfExporter exporter = new JRPdfExporter(); ExporterInput exporterInput = new SimpleExporterInput(print); // ExporterInput exporter.setExporterInput(exporterInput); // ExporterOutput OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput( "C:/jasperoutput/CustomerDataReport.pdf"); ................. Now, I want to pass an sql query say a select statement so that the PDF report generated should have only the values returned by the SQL query. I am using: parameters.put("QUERY", "Select c.FirstName, c.CompanyName from SalesLT.Customer c where c.CustomerID = 1"); but this is not working. Please help me. Thanks in advance.
  2. This is the whole program. package jasperReports; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; import net.sf.jasperreports.engine.JRDataSource; //import net.sf.jasperreports.engine.JREmptyDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.JRResultSetDataSource; //import jasperSQLConn.*; public class PdfFromXmlFile { public static void main(String[] args) throws JRException, IOException { // Compile jrxml file. JasperReport jasperReport = JasperCompileManager .compileReport("C:/jasperreport/CustomerDataReport/CustomerData.jrxml"); // Parameters for report Map<String, Object> parameters = new HashMap<String, Object>(); // DataSource // This is simple example, no database. // then using empty datasource. JRDataSource dataSource = new JRResultSetDataSource(null); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource); // Make sure the output directory exists. File outDir = new File("C:/jasperoutput"); outDir.mkdirs(); // Export to PDF. JasperExportManager.exportReportToPdfFile(jasperPrint, "C:/jasperoutput/CustomerData.pdf"); System.out.println("Pdf generated!"); } } Please tell me how to add a datasource.
  3. Hi all, I created a Java console app which takes a .jrxml file with no data source as input and renders a pdf to a specific folder. Now, I am trying to use a .jrxml which was generated with a data source. How do I add a data source in place of empty data source? (JRDataSource dataSource = new JREmptyDataSource();) Any answer is appreciated. Thanks in advance.
  4. Hi All, I am trying to create a Java based web app such as if any end user clicks on a button, it has to render the report linked to the Java application using the JasperReports and Jaspersoft Studio. There were a lot of documentation involved and I am a bit confused. Please tell me how do I go by to achieve this. Thanks in advance.
  5. @elizam, Thanks for that information. Is there way if we can create objects and the ad-hoc functionality? Or is there any other way to do it?
  6. Hi, I am new to Jaspersoft reporting. Even though, the enterprise edition has a 60-day trial offer, I wanted to check if I can write/implement the ad-hoc functionality in the community edition for future use? Or Can we create objects on top of community features? Any response is appreciated. Thanks in advance.
×
×
  • Create New...