Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Connection getConnection(String url, String usuario, String senha) throws SQLException{
- return DriverManager.getConnection(url, usuario, senha);
- }// fim do static Connection
- public static Connection getImportConnection() throws SQLException{
- return getConnection(
- "jdbc:mysql://localhost" + "/systemimportxml", "root", "12345678");
- }// fim do static Connection
- JasperPrint print = JasperFillManager.fillReport(inputStream, parametros, conexao);
- viewReportFrame(titulo, print);
- }
- public static void openReport(
- String titulo,
- InputStream inputStream,
- Map parametros,
- JRDataSource dataSource ) throws JRException {
- JasperPrint print = JasperFillManager.fillReport(inputStream, parametros, dataSource);
- viewReportFrame(titulo, print);
- }
- private static void viewReportFrame(String titulo, JasperPrint print){
- JRViewer viewer = new JRViewer(print);
- JFrame frameRelatorio = new JFrame(titulo);
- frameRelatorio.add(viewer, BorderLayout.CENTER);
- frameRelatorio.setSize(500, 500);
- frameRelatorio.setExtendedState( JFrame.MAXIMIZED_BOTH);
- frameRelatorio.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE);
- frameRelatorio.setVisible(true);
- }// fim d static void viewReportFrame
- public void abrirRelatorioFornecedor(){
- InputStream inputStream = getClass().getResourceAsStream("//Report/fornecedor.jasper");
- Map parametros = new HashMap();
- try{
- ReportUtils.openReport( "fornecedor", inputStream, parametros, ConnectionFactory.getImportConnection());
- } catch (SQLException exc){
- System.out.println(exc);
- }catch (JRException exc){
- System.out.println(exc);
- }// fim do catch
- }// fim do void abrirRelatorioFornecedor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement