thanks for the reply friend
this is for example a class (of many that i have) related with JR,
all has the same style of programming
Code:
package com.lagranjita.swf.actions;
import java.sql.Connection;
import java.sql.ResultSet;
//import java.sql.Statement;
import java.sql.PreparedStatement;
//import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.action.AbstractAction;
import org.springframework.webflow.execution.RequestContext;
import com.lagranjita.modelo.entidades.AlmacenPK;
import com.lagranjita.modelo.entidades.CabeceraSalidaAlmacen;
import net.sf.jasperreports.engine.JRResultSetDataSource;
//com.lagranjita.swf.actions.TransaccionSalidaAlmacenJasperReportAction
public class TransaccionSalidaAlmacenJasperReportAction extends AbstractAction {
private static Log logger = LogFactory.getLog("TransaccionSalidaAlmacenJasperReportAction");
private DataSource dataSource;
public void setDataSource (DataSource dataSource){
this.dataSource=dataSource;
}
@Override
protected Event doExecute(RequestContext context)throws Exception{
logger.info("doExecute");
CabeceraSalidaAlmacen cabeceraSalidaAlmacen = (CabeceraSalidaAlmacen) (context.getFlowScope().get("cabeceraSalidaAlmacenCommand"));
AlmacenPK almacenPK = cabeceraSalidaAlmacen.getAlmacenPK();
Connection connection;
PreparedStatement ps;
ResultSet resultSet;
String query = "SELECT * FROM CabeceraAlmacen c, DetalleAlmacen d, Articulo a, Medida m WHERE " +
" c.idnumero=d.idnumero AND c.serie=d.serie AND " +
" d.idArticulo=a.idArticulo AND a.idMedida=m.idMedida AND " +
" c.serie='SAL' AND c.idnumero=?";
connection = dataSource.getConnection();
ps=connection.prepareStatement(query);
ps.setString(1, almacenPK.getIdnumero());
resultSet = ps.executeQuery();
JRResultSetDataSource resultSetDataSource = new JRResultSetDataSource(resultSet);
context.getRequestScope().put("datasource", resultSetDataSource);
return success();
}
}
the class already posted is for SWF , but for spring mvc is the same history
and ensure that they are closed.
sorry for my ignorance but with this
Code:
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
is not enough?
i see that my code doesnt has a line to close the connection,
only has a line to get the connection
like
Code:
connection = dataSource.getConnection();
now for the bean definition i have this
Code:
<bean id="idTransaccionSalidaAlmacenJasperReportAction" class="com.lagranjita.swf.actions.TransaccionSalidaAlmacenJasperReportAction" >
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
i need your experience and help
thanks for advanced