Advertisement
Guest User

Untitled

a guest
Oct 6th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. public static Connection getConnection(String url, String usuario, String senha) throws SQLException{
  2. return DriverManager.getConnection(url, usuario, senha);
  3. }// fim do static Connection
  4.  
  5. public static Connection getImportConnection() throws SQLException{
  6. return getConnection(
  7. "jdbc:mysql://localhost" + "/systemimportxml", "root", "12345678");
  8. }// fim do static Connection
  9.  
  10. JasperPrint print = JasperFillManager.fillReport(inputStream, parametros, conexao);
  11. viewReportFrame(titulo, print);
  12. }
  13.  
  14. public static void openReport(
  15. String titulo,
  16. InputStream inputStream,
  17. Map parametros,
  18. JRDataSource dataSource ) throws JRException {
  19.  
  20. JasperPrint print = JasperFillManager.fillReport(inputStream, parametros, dataSource);
  21. viewReportFrame(titulo, print);
  22. }
  23.  
  24. private static void viewReportFrame(String titulo, JasperPrint print){
  25. JRViewer viewer = new JRViewer(print);
  26.  
  27. JFrame frameRelatorio = new JFrame(titulo);
  28.  
  29. frameRelatorio.add(viewer, BorderLayout.CENTER);
  30.  
  31. frameRelatorio.setSize(500, 500);
  32.  
  33. frameRelatorio.setExtendedState( JFrame.MAXIMIZED_BOTH);
  34.  
  35. frameRelatorio.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE);
  36.  
  37. frameRelatorio.setVisible(true);
  38. }// fim d static void viewReportFrame
  39.  
  40. public void abrirRelatorioFornecedor(){
  41. InputStream inputStream = getClass().getResourceAsStream("//Report/fornecedor.jasper");
  42.  
  43. Map parametros = new HashMap();
  44.  
  45. try{
  46. ReportUtils.openReport( "fornecedor", inputStream, parametros, ConnectionFactory.getImportConnection());
  47. } catch (SQLException exc){
  48. System.out.println(exc);
  49. }catch (JRException exc){
  50. System.out.println(exc);
  51. }// fim do catch
  52. }// fim do void abrirRelatorioFornecedor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement