1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
public void Impression(ActionEvent a) {
Connection conn = null;
String userName = "root";
String password = "";
String url = "jdbc:mysql://localhost:3306/nomdelabase";
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection(url, userName, password);
System.out.println("Database connection established");
JasperDesign jasperDesign = JRXmlLoader
.load("ChemeinduRapport\\titre.jrxml");
Map parameters = new HashMap();
File jasperReportFile = new File( "ChemeinduRapport\\titre.jasper" );
JasperPrint jasperPrint = JasperFillManager.fillReport(
jasperReportFile.getPath(), parameters, conn);
// - Cr�ation du rapport au format PDF
JasperExportManager.exportReportToPdfFile(jasperPrint,
"NomRapport.pdf");
System.out.println("export pdf effectue");
Process p = Runtime.getRuntime().exec(
"rundll32 url.dll,FileProtocolHandler ListeVehicules.pdf");
p.waitFor();
System.out.println("Done.");
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JRException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
Partager