B4J Library jJasperReports Library

Discussion in 'B4J Libraries & Classes' started by Juan Marrero, Sep 21, 2018.

  1. Juan Marrero

    Juan Marrero Active Member Licensed User

    Hi. I want to share this jJasperReports library with the community.
    It needs several libraries to work. I provided a link: download
    You also need to download databases jdbc drivers: sql jdts, mysql and oracle
    All jars need to be placed in Additional Libraries folder.
    In the B4J project you need to add a jar file: #AdditionalJar: itext-2.1.7.js1
    Library files and a small example is provided.
    Please feel free to test the library.
    Note: for some reason when using SubReports, the compiled (.jasper) files need to be in the same level as the app jar file. XML Reports (.jrxml) can be in any other folder different from the app jar file. (e.g. if report.jrxml is in File.DirApp & "/reports" then all compiled (.jasper) subreports need to be in File.DirApp. In the example provided .jrxml and .jasper are in the same level as jaspertest.jar.

    v1.00 - Release
    v1.10 - SQLite support added. MySQL useSSL variable added.
    v1.12 - Changed the way the JasperViewer works. Now you can set the form to full screen, use the default size and location or set a specific size and location.
    v1.13 - Added method PrintDirectlyToPrinter.
    v1.20 - Access support added via uCanAccess jdbc driver. Note: When creating reports in Jaspersoft Studio you need to add all jar files that ucanaccess needs. The metadata won't work but you can create a query and it will work.

    Attached Files:

    Last edited: Mar 20, 2019
    Don Oso, inakigarm, XbNnX_507 and 5 others like this.
  2. Roberto P.

    Roberto P. Well-Known Member Licensed User

    can you post some images?
    thank you
  3. Juan Marrero

    Juan Marrero Active Member Licensed User


    If you downloaded jaspertest.zip, please download it again. I copy/pasted something that ended in an error loading .jasper file.
  4. afields

    afields Member Licensed User

    very nice!. is it possible to connect also with sqlite?
    thank you.
  5. XbNnX_507

    XbNnX_507 Active Member Licensed User

    Same question here.
  6. Juan Marrero

    Juan Marrero Active Member Licensed User

    Will look into it.
    XbNnX_507 likes this.
  7. Juan Marrero

    Juan Marrero Active Member Licensed User

    Added new Library including sqlite support and a screenshot of the sqlite report on the first post. SQLite version used was sqlite-jdbc-3.23.1.jar.
  8. giannimaione

    giannimaione Well-Known Member Licensed User

    it works very well!

    my report use MySql,
    what does it mean, in log ?
    Sun Sep 23 20:09:17 CEST 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.

    232018 8:09:19 PM net.sf.jasperreports.engine.export.PdfGlyphRenderer determinePatchedItext

    AVVERTENZA: Unpatched iText found, cannot use glyph rendering
  9. afields

    afields Member Licensed User

    hello. sorry by the new library that was added is an update of one that's already here?. because i cannot locate that new library.
    Thank you but anyway it's a very nice library
  10. Juan Marrero

    Juan Marrero Active Member Licensed User

    Forgot about that. I'll add a variable to set useSSL true or false. If MySQL is configured with SSL and you try to connect without specifying useSSL=false MySQL doesn't let you connect (most of the time).
    The Unpatched iText Warning is because JasperReports use a modified iText library.
  11. Juan Marrero

    Juan Marrero Active Member Licensed User

    I replaced the original upload with the new one. The initial library was deleted. Next time I'll leave the old library and add the new one as a different upload.
    afields likes this.
  12. afields

    afields Member Licensed User

    hello to all!
    Very cool that library. i've tried with sqlite (it's the one that i have more records) and also few reports designed with jasper. Each of those reports also have parameters. using jasper.parameters it's working very well.
  13. Juan Marrero

    Juan Marrero Active Member Licensed User

    @giannimaione I added a new version of the library where you can set useSSL to false when connecting to MySQL. I also checked the JasperDesign and JasperDesignQuery functions and made them work (I used an example from internet which causes errors compiling the report but now works). Using JasperDesign and JasperDesignQuery you can change the report's query design at runtime.
    giannimaione likes this.
  14. Juan Marrero

    Juan Marrero Active Member Licensed User

    Glad to hear that! :D
  15. Juan Marrero

    Juan Marrero Active Member Licensed User

    v.13 - Added a way to print directly to selected printer.

    Dim jasper As JasperReports
    Dim report As JasperReport
    Dim print As JasperPrint
    Dim conn As JasperConnection
    Dim design As JasperDesign
    Dim query As JasperDesignQuery
    Dim printers As List = Printer_Static.GetAllPrinters
    Dim printersList As List
    For Each prt As Printer In printers
    Dim selPrinter As String
    Dim sel As Int = fx.InputList(MainForm, printersList, "Select Printer:""Printer", -1)
    If sel <> fx.DialogResponse.CANCEL Then
           selPrinter = printersList.Get(sel)
    End If
    File.Combine(File.DirApp, "mysql_example.jrxml"))
    "select reference, code, name, pricesell from products where name like '%SQL' order by name asc")
       query = jasper.query
       design = jasper.design
       report = jasper.CompileXML2(design)
       conn = jasper.getConnectionMySQL(
    "localhost""3306""databasename""user""password"False'useSSL = true or false
       print = jasper.Print(report, jasper.parameters, conn)
    If selPrinter <> "" Then
           jasper.PrintDirectlyToPrinter(print, selPrinter, jasper.msn_NA_LETTER)
    End If
    I used jFX8Print library to select the printer name.
    Erel and Don Oso like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice