Jump to content
Changes to the Jaspersoft community edition download ×

ireport and charts


mahdi

Recommended Posts

hi everybody,

 

i have a report build by ireport, that display a chart. when i execute this report into ireport, everything go well, but when i execute it into java, it throws a FATAL error:

 

org.commons.digester.Digester error

FATAL: parse error at line 108 column -1: The element "{0}" doesn't allow other entries; "sectionHyperlink" is not allowed.

org.xml.sax.SAXParseException: the element "{0}" isdoesn't allow other entries; "sectionHyperlink" is not allowed.

---- This is a translation from french ----

my java code is the following:

 

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

import java.util.*;

import java.io.*;

 

import net.sf.jasperreports.engine.*;

import net.sf.jasperreports.engine.design.*;

import net.sf.jasperreports.engine.xml.*;

import net.sf.jasperreports.view.JasperViewer;

 

import sun.jdbc.odbc.JdbcOdbcDriver;

 

public class App {

// attributes

private static Connection conn = null;

private static Statement stmt = null;

private static ResultSet rs = null;

/// connection

public static Connection getConnect() {

try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//.newInstance();//("com.mysql.jdbc.Driver").newInstance();

conn = DriverManager.getConnection("" +

"jdbc:odbc:myodbc", "manager", "manager");

return conn;

} catch(Exception ex) {

System.out.println("SQLException1111X: " + ex.getMessage());

return null;

}

}

public static void main(String[] args) {

try {

System.out.println("here1");

 

System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser");

 

Map parameters = new HashMap();

parameters.put("idProcess", "14");

parameters.put("dateBefore", "2006-01-01");

parameters.put("dateAfter", "2006-12-31");

parameters.put("SUBREPORT_DIR", ".\");

 

JasperDesign jasperDesign;

JasperReport jasperReport;

JasperPrint jasperPrint;

 

Connection conn = App.getConnect();

 

jasperDesign = JRXmlLoader.load("C:\mahdi\Stage2A\REPORT\NASLO.jrxml");//Report_TdB.jrxml");

jasperReport = JasperCompileManager.compileReport(jasperDesign);

jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);

JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\mahdi\Stage2A\REPORT\NASLO.jrxml");

JasperViewer.viewReport(jasperPrint);

} catch (Exception ex) {

System.out.println(ex.getMessage());

}

}

}

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

hi again,

 

i have found the code for executing charts build by ireport:

 

File reportFile = new File("C:\JASPER_FILE_PATH\file.jasper");

JasperReport jasperReport = (JasperReport)JRLoader.loadObject(eroprtFile.getPath());

Map Parameters = new HashMap();

parameters.put("parmater_name", "parameter_value");

conn = getConnexion(); // u have to define this function

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);

JasperViewer.viewReport(jasperPrint);

 

have a fun

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...