can anyone help me to send the code for Jasper Reporting in
java?plz
Answer Posted / ram
//this code is very easy any one can understand easily
//1. these are the packages which we need to import
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JRDesignQuery;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.view.JasperViewer;
//2. this is the java code for developing reports
try{
Connection con=(Connection)
Connectivity.makeconnection();// Database Connection
File path=new File("Report/");
JasperDesign jasperDesign =
JRXmlLoader.load(path.getAbsolutePath()+"\\allbooksreport.jrxml");//here
allbooksreport is my jrxml file name ...//xml file
Map parameters = new HashMap();
parameters.put("DataSource" ,con);
JRDesignQuery query =new JRDesignQuery();
query.setText("select * from add_book");
jasperDesign.setQuery(query);
JasperReport jasperReport =
JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint =
JasperFillManager.fillReport(jasperReport,parameters,con);
JasperViewer vwrpt = new
JasperViewer(jasperPrint,false);
vwrpt.show(); //...//view the report
vwrpt.setTitle("All Books Report");
} catch(Exception e) {
e.getMessage();
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Explain about struts?
What’s the difference between struts and turbine? What’s the difference between struts and espresso?
In which order struts framework searches for a message bundle?
What is the difference between validation.xml and validator-rules.xml files in struts?
What is the apache struts vulnerability?
What are the struts2 error message keys that can come during file uploading process?
Explain struts.devmode?
How can forward action be used to restrict a strut application to mvc?
How to use forward action to restrict a strut application to mvc?
Where should struts xml be placed?
How properties of a form are validated in Struts?
What does action do in struts?
Why are struts tightly coupled?
Which servlet does the struts framework use?
What is the purpose of @after?