Save Template to Database

  • Last update:  2020-12-22
  • I. Requirement

    Scenario: If you save ready-made template files on the hard disk, once the hard disk fails or crashes, the template files may be missing irreversibly, which will cause bad consequences.

    Function: To lower the risks of template file missing, the function enables you to save all finalized template files into the database. In this way, even if the hard disk crashes, you can still extract these template files from the database for backups.

    Save a .cpt template file into MySQL database. Click the dataset named report and then click DB Query>Dataset. Type SELECT * FROM REPORT

    A Preview window pops up, as shown in the figure below:

    How to save a .cpt template file into the database? Specific steps are shown below.

    II. Steps

    1. Create a report in database

    Create a report in the database. The report should contain two fields, cptname (string) and cpt (Blob).

     


    2. Edit codes for saving the template

    Note: It is necessary to introduce the JAR package under FineReport’s designer. Detailed codes are listed below:

    https://github.com/finereport-overseas/example/blob/release/10.0/src/main/java/com/fr/demo/SaveReportToDatabase.java

    See the specific steps in Start the Designer in Eclipse.

    Note: This program connects to the database with JDBC. Before editing codes, load the driver package of the corresponding database into project.

    Additionally, some codes should be modified according to actual report-related environment path and database.

    Moreover, if the database is case insensitive (which means treating or interpreting upper- and lowercase letters as being the same), it is not necessary to modify the codes; if the database is case sensitive, add double quotation marks to the report name, that is,  insert into \"report\" values(?,?)


    III. Compiling and execution

    Run the compiled program and you will find newly added data are displayed in the database.

     

     


    Attachment List


    Theme: Secondary Development
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy