Hello,

*Problem*: I created a .jrxml report template in iReports that is using an
Oracle database to retrieve data. Now I want to plug in this report into a
existing webapp using the Struts2 plugin. The webapp uses JDBC to connect to
the database. I'm not able to figure out what value to use for the *datasource
*param in the struts.xml (<param name="dataSource">???</param>) so that when
I click on view report on the GUI, the compiled report template from
the *location
*param would be called and the data from the Oracle database given in
the *datasource
*param would be used to generate the report.

*Background*: I've searched high and low and seen the last conversation on
this between Milan
Milanovic<http://www.nabble.com/user/UserProfile.jtp?user=1020045>and
Dave Newton but inspite of downloading the JasperReportResult.java
(that
Milan has kindly posted), I'm not able to get this to work. After I got the
JasperReportResult.java, I got errors while compiling that required the
classes com.opensymphony.xwork2.util.logging.Logger and LoggerFactory so I
got xwork-2.1.0.jar that has the logging classes (was using xwork-2.0.5
earlier). Now I'm getting an error on line 288  that says Connection cannot
be resolved (Connection conn = (Connection)stack.findValue(connection)). I
tried importing java.sql package that fixes the compilation but still does
not work Now, I get the error:

java.lang.ClassCastException: java.lang.String
        
org.apache.struts2.views.jasperreports.JasperReportsResult.doExecute(JasperReportsResult.java:288)
        
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)

.

Please help! Many thanks in advance. Given below is my action class and
setting in struts.xml.

I've the following in struts.xml:
<param name="connection">connect</param>

and the following in my action:
package com.db.mq.mon.report.ui.test.action;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.util.ArrayList;

import com.opensymphony.xwork2.ActionSupport;


 *
 * Jan 9, 2009
 *
 */
public class AppReportAction extends ActionSupport {

    /**
     *
     */
    private static final long serialVersionUID = 7763977968848348929L;

    private Connection myConn;
    private String connect;
    private ArrayList<Connection> dataSource = new ArrayList<Connection>();



    public String execute() throws Exception {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    myConn =
DriverManager.getConnection("jdbc:oracle:thin:@192.168.120.102:1521:tvmdev",
"user2", "sena120");
    connect = "jdbc:oracle:thin:@192.168.120.102:1521:tvmdev";
    dataSource.add(myConn);

        return SUCCESS;
    }



    /**
     * @return the dataSource
     */
    public ArrayList getDataSource() {
        return dataSource;
    }



    /**
     * @param dataSource the dataSource to set
     */
    public void setDataSource(ArrayList dataSource) {
        this.dataSource = dataSource;
    }



    /**
     * @return the connect
     */
    public String getConnect() {
        return connect;
    }



    /**
     * @param connect the connect to set
     */
    public void setConnect(String connect) {
        this.connect = connect;
    }

}



<http://www.nabble.com/user/UserProfile.jtp?user=1020045>

Reply via email to