Guest User

Untitled

a guest
Dec 8th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  2. JasperReport masterReport = null;
  3. try
  4. {
  5. masterReport = (JasperReport) JRLoader.loadObject(System.getProperty("user.dir") +
  6. "/src/org/reportes/report3.jasper");
  7. }
  8. catch (JRException e) {}
  9. Map parametro = new HashMap();
  10. parametro.put("parametro",null);
  11. try {
  12. Class.forName("com.mysql.jdbc.Driver");
  13. } catch (ClassNotFoundException ex) {
  14.  
  15. Exceptions.printStackTrace(ex);
  16. }
  17. Connection conn = null;
  18. try {
  19. conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/centromedico","root","");
  20. JasperPrint jasperPrint;
  21. try {
  22. jasperPrint = JasperFillManager.fillReport(masterReport, parametro, conn);
  23. JasperViewer jviewer = new JasperViewer(jasperPrint,false);
  24. jviewer.setVisible(true);
  25. } catch (JRException ex) {
  26. Exceptions.printStackTrace(ex);
  27. }
  28.  
  29. } catch (SQLException ex) {
  30.  
  31. Exceptions.printStackTrace(ex);
  32. }
  33. if (conn == null)
  34. try {
  35. conn.close();
  36. } catch (SQLException ex) {
  37. Exceptions.printStackTrace(ex);
  38. }
  39. }
Add Comment
Please, Sign In to add comment