Jump to content
Changes to the Jaspersoft community edition download ×

help me with this code!!! please


2005 IR Help

Recommended Posts

By: Arcangellous - angel_rivera

help me with this code!!! please

2005-06-27 14:23

Hello i just want to genrate a simple report

 

this is the code

 

 

package src;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

import java.util.HashMap;

import java.util.Map;

import net.sf.jasperreports.engine.JRException;

import net.sf.jasperreports.engine.JasperCompileManager;

import net.sf.jasperreports.engine.JasperExportManager;

import net.sf.jasperreports.engine.JasperFillManager;

import net.sf.jasperreports.engine.JasperPrint;

import net.sf.jasperreports.engine.JasperReport;

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

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

import net.sf.jasperreports.view.JasperViewer;

 

 

 

public class reportExample {

 

 

 

 

public static void main(String[] args) throws JRException, ClassNotFoundException {

 

try

{

System.out.println("begin");

// First, load JasperDesign from XML and compile it into JasperReport

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

System.out.println("2");

JasperDesign jasperDesign = JRXmlLoader.load("C:\Documents and Settings\Administrador\Mis documentos\Imss\reportes\capitalesConstitutivos.jrxml");

System.out.println("3");

 

 

JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

System.out.println("4");

// Second, create a map of parameters to pass to the report.

Map parameters = new HashMap();

parameters.put("isPaginated", "true");

 

// Third, get a database connection

 

 

// Fourth, create JasperPrint using fillReport() method

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,

parameters, getConnection());

 

// You can use JasperPrint to create PDF

JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\reporteSalidaPDF.pdf");

 

// Or to view report in the JasperViewer

JasperViewer.viewReport(jasperPrint);

System.out.println("done");

}

catch(JRException e)

{

e.printStackTrace();

}

catch(SQLException e)

{

e.printStackTrace();

 

}

finally

{}

}

 

 

/**Metodo para crear la conexion a DB*/

private static Connection getConnection() throws ClassNotFoundException, SQLException {

//Configuració®¤e la conexi󮮦nbsp;

String driver = "oracle.jdbc.driver.OracleDriver";

String connectString = "jdbc:oracle:thin:@11.254.14.152:1523:subsidio";

String user = "nssa_desa";

String password = "milan";

 

Class.forName(driver);

Connection conn = DriverManager.getConnection(connectString, user, password);

 

//Retornamos la conexió®¥stablecida.

return conn;

}

 

}

 

 

 

 

but after to print "4" trhows the next errors

 

 

 

begin

2

3

java.io.IOException: CreateProcess: javac -classpath C:eclipseworkspacereportExampleclasses;C:iReport-0.5.0libxercesImpl.jar;C:iReport-0.5.0libcommons-logging.jar;C:iReport-0.5.0libcommons-logging-api.jar;C:iReport-0.5.0libcommons-beanutils.jar;C:jarsxerces.jar;C:iReport-0.5.0libcommons-digester.jar;C:iReport-0.5.0libcommons-collections.jar;C:iReport-0.5.0libjasperreports-0.6.7.jar C:eclipseworkspacereportExamplecapitalesConstitutivos.java error=2

at java.lang.Win32Process.create(Native Method)

at java.lang.Win32Process.<init>(Unknown Source)

at java.lang.Runtime.execInternal(Native Method)

at java.lang.Runtime.exec(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClass(JRJavacCompiler.java:59)

at net.sf.jasperreports.engine.design.JRAbstractClassCompiler.compileReport(JRAbstractClassCompiler.java:117)

at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:105)

at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:211)

at src.reportExample.main(reportExample.java:42)

 

NESTED BY :

net.sf.jasperreports.engine.JRException: Error compiling report java source file : C:eclipseworkspacereportExamplecapitalesConstitutivos.java

at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClass(JRJavacCompiler.java:84)

at net.sf.jasperreports.engine.design.JRAbstractClassCompiler.compileReport(JRAbstractClassCompiler.java:117)

at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:105)

at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:211)

at src.reportExample.main(reportExample.java:42)

 

 

 

any idea what can i do?

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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...