Re: JasperReports Plugin:How to specify JDBC connection?

2009-01-27 Thread Dave Newton

Mel Rosenberg wrote:

I have been working on using Jasper with Struts2 2.0.11.  Looking at the
documentation it seems that the dataSource param is looking for a list.  The
question is what is in the list.  Is it a list of connection parameters to
the database, ie.. url, login name, password...  or is it a list of results?

Can anyone point me in the right direction?  I have searched the web and
cant find an article that shows how to connect to a database and produce a
JasperReport from Struts2.


The list is a JR data source used as the iterable object in the report 
(list of "results").


Dave


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: JasperReports Plugin:How to specify JDBC connection?

2009-01-27 Thread dusty

List = ResultSet from Oracle.  If you can project your resultset into Objects
then you can address properties in the jasper report by fieldName.  To be
perfectly honest it has been a while since I have worked with raw JDBC
objects, so I cannot remember what object you create to execute SQL to
return a list.  But lets say its a Query object.  If you cannot project to
objects then your list is usually filled with Objects[]s.  Each entry in
each array represents a column value in the row.  So row = Object array. 
When you are passing a List to JasperReports I am not sure how to
address the fields but I am sure the syntax is something like field[0].  I
don't know if there is a keyword like "field" or its just [0].



Mel Rosenberg-2 wrote:
> 
> I have been working on using Jasper with Struts2 2.0.11.  Looking at the
> documentation it seems that the dataSource param is looking for a list. 
> The
> question is what is in the list.  Is it a list of connection parameters to
> the database, ie.. url, login name, password...  or is it a list of
> results?
> 
> Can anyone point me in the right direction?  I have searched the web and
> cant find an article that shows how to connect to a database and produce a
> JasperReport from Struts2.
> 
> Thanks in advance.
> Mel
> 
> -Original Message-
> From: ravindra [mailto:ravin...@btpsoft.com]
> Sent: Tuesday, January 13, 2009 2:36 AM
> To: 'Struts Users Mailing List'
> Subject: RE: JasperReports Plugin:How to specify JDBC connection?
> 
> 
>>>>>*param in the struts.xml (???)
> 
> The param should be the name of the list object which is used to generate
> the report.For example,
> 
> You should have a List mypojoList; as a property in your
> database
> which is used to generate the data in the table list.You should populate
> the
> list object in your prepare method.
> 
> ( mypojoList
> 
> -Original Message-
> From: Rajeshwari Godbole [mailto:rgodb...@gmail.com]
> Sent: Tuesday, January 13, 2009 2:12 PM
> To: user@struts.apache.org
> Subject: JasperReports Plugin:How to specify JDBC connection?
> 
> 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 (???) 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(JasperR
> eportsResult.java:288)
> 
> org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSuppor
> t.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:
> connect
> 
> 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 dataSource = new
> ArrayList();
> 
> 
> 
> public String execute() throws Exception {
> DriverManager.

RE: JasperReports Plugin:How to specify JDBC connection?

2009-01-27 Thread Mel Rosenberg
I have been working on using Jasper with Struts2 2.0.11.  Looking at the
documentation it seems that the dataSource param is looking for a list.  The
question is what is in the list.  Is it a list of connection parameters to
the database, ie.. url, login name, password...  or is it a list of results?

Can anyone point me in the right direction?  I have searched the web and
cant find an article that shows how to connect to a database and produce a
JasperReport from Struts2.

Thanks in advance.
Mel

-Original Message-
From: ravindra [mailto:ravin...@btpsoft.com]
Sent: Tuesday, January 13, 2009 2:36 AM
To: 'Struts Users Mailing List'
Subject: RE: JasperReports Plugin:How to specify JDBC connection?


>>>>*param in the struts.xml (???)

The param should be the name of the list object which is used to generate
the report.For example,

You should have a List mypojoList; as a property in your database
which is used to generate the data in the table list.You should populate the
list object in your prepare method.

( mypojoList

-Original Message-
From: Rajeshwari Godbole [mailto:rgodb...@gmail.com]
Sent: Tuesday, January 13, 2009 2:12 PM
To: user@struts.apache.org
Subject: JasperReports Plugin:How to specify JDBC connection?

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 (???) 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(JasperR
eportsResult.java:288)

org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSuppor
t.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:
connect

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 dataSource = new ArrayList();



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>



-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: JasperReports Plugin:How to specify JDBC connection?

2009-01-13 Thread ravindra


*param in the struts.xml (???) 

The param should be the name of the list object which is used to generate
the report.For example,

You should have a List mypojoList; as a property in your database
which is used to generate the data in the table list.You should populate the
list object in your prepare method.

( mypojoList

-Original Message-
From: Rajeshwari Godbole [mailto:rgodb...@gmail.com] 
Sent: Tuesday, January 13, 2009 2:12 PM
To: user@struts.apache.org
Subject: JasperReports Plugin:How to specify JDBC connection?

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 (???) 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
Milanovicand
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(JasperR
eportsResult.java:288)

org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSuppor
t.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:
connect

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 dataSource = new ArrayList();



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;
}

}







-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org