plange Posted August 8, 2017 Share Posted August 8, 2017 Hallo,how may I fill a JasperReport with a MSSQL 2014 XMLA Connection in Java without JasperServer and export PDF?I use Jasper 6.4.1, java 8 and Microsoft Sql Server 2014 THIS NOT WORK!!!public String createErgebnis() { try { String strSource = ""; String strDestination = ""; String strDestinationO = ""; String strPrintReport = ""; Map<String, Object> params = null; params = new HashMap<String, Object>(); JasperPrint jasperPrint = null; File fPath = null; File fTempPath = null; String strPfad = null; String strTempPath = null; try { fPath = new ClassPathResource("VAADIN/themes/jasper/reports/").getFile(); strPfad = fPath.getAbsolutePath(); fTempPath = new ClassPathResource("VAADIN/themes/jasper/tempreports/").getFile(); strTempPath = fTempPath.getAbsolutePath(); } catch (IOException e) { log.error("Pfad konnte nicht gelesen werden: " + e); } SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); String uhrzeit = sdf.format(new Date()); uhrzeit = uhrzeit.replaceAll(":", "_"); strPrintReport = "B_" + uhrzeit + "_" + "admin" + ".jrprint"; strPrintReport = strTempPath + "/" + strPrintReport; JRConcurrentSwapFile jrSwapFile = new JRConcurrentSwapFile(strTempPath, 1024, 4); JRSwapFileVirtualizer fileVirtualizer = new JRSwapFileVirtualizer(2, jrSwapFile); params.put(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_URL, Konstanten._URLPVCUBE); params.put(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_DATASOURCE, Konstanten._DSPVCUBE); params.put(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_CATALOG, Konstanten._CATPVCUBE); params.put(net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuterFactory.PARAMETER_XMLA_URL, Konstanten._URLPVCUBE); params.put(net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuterFactory.PARAMETER_XMLA_DATASOURCE, Konstanten._DSPVCUBE); params.put(net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuterFactory.PARAMETER_XMLA_CATALOG, Konstanten._CATPVCUBE); params.put("parmP1", "Peter"); String img = strPfad + "/logo.gif"; params.put("LogoJPG", img); params.put(JRParameter.REPORT_VIRTUALIZER, fileVirtualizer); // Seitenumbrusch einschalten params.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.FALSE); if (Konstanten._USERCUBE != null && Konstanten._USERCUBE.length() > 0) { String tmpPassword = Konstanten._PWQCUBE; Authenticator.setDefault(new HTTPAuth(Konstanten._USERCUBE, tmpPassword)); params.put(JRXmlaQueryExecuterFactory.QUERY_EXECUTER_FACTORY_PREFIX, "xmla-mdx"); params.put(net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuterFactory.PARAMETER_XMLA_USER, Konstanten._USERCUBE); params.put(net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuterFactory.PARAMETER_XMLA_PASSWORD, tmpPassword); } // PDF strSource = "Vordruck anzeigen V51.jasper"; strDestinationO = "B_" + uhrzeit + "_" + "admin" + ".pdf"; strSource = strPfad + "/" + strSource; strDestination = strTempPath + "/" + strDestinationO; try { jasperPrint = JasperFillManager.fillReport(strSource, params); JRPdfExporter exporter = new JRPdfExporter(); File filePdf = new File(strPrintReport); final ByteArrayOutputStream output = new ByteArrayOutputStream(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(output)); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); exporter.setConfiguration(configuration); exporter.exportReport(); } catch (Exception e) { log.error("Error in pdf modul! " + e); } } catch (Exception e) { log.error("Error! " + e); } return ""; }[/code] Where can I find a Example?ThanksPatrick Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now