Hi,
when i click on print option in print dialog box, it throws an error.
Class.forName("com.mysql.jdbc.Driver"); Connection con= DriverManager.getConnection(url, user, pass); String report = "/home/rajankit911/eclipse-oxygen-workplace/General/src/testing/Blank_A4.jrxml"; JasperDesign jd = JRXmlLoader.load(report); int id=1; String sql = "SELECT * FROM Cust_details where id = "+id; JRDesignQuery newQuery = new JRDesignQuery(); newQuery.setText(sql); jd.setQuery(newQuery); JasperReport jr = JasperCompileManager.compileReport(jd); JasperPrint jp = JasperFillManager.fillReport(jr, null, con); JasperPrintManager.printReport(jp, true); con.close();
Error details are:
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. Fri Jul 06 13:50:27 IST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" net.sf.jasperreports.engine.JRException: Error printing report. at net.sf.jasperreports.engine.print.JRPrinterAWT.printPages(JRPrinterAWT.java:215) at net.sf.jasperreports.engine.JasperPrintManager.print(JasperPrintManager.java:246) at net.sf.jasperreports.engine.JasperPrintManager.print(JasperPrintManager.java:133) at net.sf.jasperreports.engine.JasperPrintManager.printReport(JasperPrintManager.java:329) at testing.JDBC.main(JDBC.java:43) Caused by: java.awt.print.PrinterIOException at sun.print.PSPrinterJob$PrinterSpooler.run(PSPrinterJob.java:737) at java.security.AccessController.doPrivileged(Native Method) at sun.print.PSPrinterJob.endDoc(PSPrinterJob.java:792) at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1563) at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1391) at net.sf.jasperreports.engine.print.JRPrinterAWT.printPages(JRPrinterAWT.java:201) ... 4 more Caused by: java.io.IOException: error=1 running: '/usr/bin/lpr' '-PCanon_MF230' '-JJasperReports - Blank_A4' '/tmp/javaprint1165658235420093751.ps' lpr: Canon_MF230: unknown printer at sun.print.PSPrinterJob$PrinterSpooler.handleProcessFailure(PSPrinterJob.java:711) at sun.print.PSPrinterJob$PrinterSpooler.run(PSPrinterJob.java:734) ... 9 more
Please help me to resolve this error.
4 Answers:
Posted on July 6, 2018 at 3:12pm
https://stackoverflow.com/questions/3737992/noclassdeffounderror-org-slf...
It looks like you need add additional dependencies
Posted on July 7, 2018 at 6:51pm
>Caused by: java.io.IOException: error=1 running: '/usr/bin/lpr' '-PCanon_MF230' '-JJasperReports - Blank_A4' '/tmp/javaprint1165658235420093751.ps'
>lpr: Canon_MF230: unknown printer
It looks like error with the printer. Seems like it's not setup properly for linux.