HashMap hm = null;
System.out.println("Usage: ReportGenerator ....");
try {
System.out.println("Start ....");
// Get jasper report
String jrxmlFileName = "/Users/alejandro/JaspersoftWorkspace/MyReports/Personas.jrxml";
String jasperFileName = "/Users/alejandro/JaspersoftWorkspace/MyReports/Personas.jasper";
String pdfFileName = "/Users/alejandro/JaspersoftWorkspace/MyReports/Personas.pdf";
//JasperCompileManager.compileReportToFile(jrxmlFileName, jasperFileName);
// String dbUrl = props.getProperty("jdbc.url");
String dbUrl = "jdbc:mysql://127.0.0.1:3306/pistaamerica";
// String dbDriver = props.getProperty("jdbc.driver");
String dbDriver = "com.mysql.jdbc.Driver";
// String dbUname = props.getProperty("db.username");
String dbUname = "usuarioweb";
// String dbPwd = props.getProperty("db.password");
String dbPwd = "americaforever";
// Load the JDBC driver
Class.forName(dbDriver);
// Get the connection
Connection conn = DriverManager.getConnection(dbUrl, dbUname, dbPwd);
// Generate jasper print
JasperPrint jprint = (JasperPrint) JasperFillManager.fillReport(jasperFileName, hm, conn);
JasperViewer jasperviewer = new JasperViewer(jprint);
jasperviewer.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
jasperviewer.setVisible(true);
// Export pdf file
//JasperExportManager.exportReportToPdfFile(jprint, pdfFileName);
//JasperViewer.viewReport(jprint);
} catch (Exception e) {
System.out.print("Exceptiion" + e);
}
No hay comentarios:
Publicar un comentario