Jasper Reports compile ERROR

1.8k views Asked by At

I'm getting a problem when I try to compile my Java code, using Jasper Reports

I have followed this tutorial: https://www.mkyong.com/java/reporting-in-java-using-dynamicreports-and-jasperreports/

That's my code:

public static void main(String[] args) throws SQLException, ClassNotFoundException {
    Class.forName("com.mysql.jdbc.Driver");
    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/jasper", "root", "root");

    JasperReportBuilder report = DynamicReports.report();// a new report

    report.columns(Columns.column("Customer Id", "id", DataTypes.integerType()),
            Columns.column("First Name", "first_name", DataTypes.stringType()),
            Columns.column("Last Name", "last_name", DataTypes.stringType()),
            Columns.column("Date", "date", DataTypes.dateType()))
            .title(// title of the report
                    Components.text("SimpleReportExample").setHorizontalAlignment(HorizontalAlignment.CENTER))
            .pageFooter(Components.pageXofY())// show page number on the
                                                // page footer
            .setDataSource("SELECT id, first_name, last_name, date FROM customers", connection);

}

That's my pom.xml'dependences:

<dependencies>
        <!-- DynamicReports -->
    <dependency>
        <groupId>net.sourceforge.dynamicreports</groupId>
        <artifactId>dynamicreports-core</artifactId>
        <version>3.1.3</version>
    </dependency>

        <!-- MySQL database driver -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.25</version>
    </dependency>
</dependencies>

My strack trace:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    JasperReportBuilder cannot be resolved to a type
    DynamicReports cannot be resolved
    Columns cannot be resolved
    DataTypes cannot be resolved
    Columns cannot be resolved
    DataTypes cannot be resolved
    Columns cannot be resolved
    DataTypes cannot be resolved
    Columns cannot be resolved
    DataTypes cannot be resolved
    Components cannot be resolved
    HorizontalAlignment cannot be resolved to a variable
    Components cannot be resolved

    at test.Test.main(Test.java:20)
0

There are 0 answers