fixes bug #7413
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@55809 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
8e06490399
commit
a6e42ca262
|
@ -29,7 +29,15 @@ public class ArrayDataSource implements IDataSource {
|
|||
public ArrayDataSource(Relatorio relatorio) throws Exception {
|
||||
this.relatorio = relatorio;
|
||||
this.dados = new ArrayList<Map<String, Object>>();
|
||||
try {
|
||||
this.initDados();
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
if(this.relatorio != null) {
|
||||
this.relatorio.closeConnection();
|
||||
}
|
||||
}
|
||||
this.rowNum = -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,15 @@ public class DataSource implements IDataSource {
|
|||
|
||||
public DataSource(Relatorio relatorio) throws Exception {
|
||||
this.relatorio = relatorio;
|
||||
try {
|
||||
this.initDados();
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
if(this.relatorio != null) {
|
||||
this.relatorio.closeConnection();
|
||||
}
|
||||
}
|
||||
this.rowNum = -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package com.rjconsultores.ventaboletos.relatorios.utilitarios;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.rjconsultores.ventaboletos.relatorios.render.RenderRelatorioJasper;
|
||||
|
||||
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
||||
|
||||
/**
|
||||
* @author Bruno H. G. Gouvêa <bruno@rjconsultores.com.br>
|
||||
*
|
||||
|
@ -90,12 +89,7 @@ public abstract class Relatorio {
|
|||
public void setCustomDataSource(boolean closeConnection,IDataSource iDataSource) {
|
||||
this.customDataSource = iDataSource;
|
||||
if (closeConnection){
|
||||
try {
|
||||
if (!this.conexao.isClosed())
|
||||
this.conexao.close();
|
||||
} catch (SQLException e) {
|
||||
log.error("Erro ao fechar a conexion", e);
|
||||
}
|
||||
closeConnection();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,12 +120,9 @@ public abstract class Relatorio {
|
|||
conteudo = this.render.render(saida);
|
||||
|
||||
} catch (Exception e) {
|
||||
if (!this.conexao.isClosed())
|
||||
this.conexao.close();
|
||||
throw e;
|
||||
} finally {
|
||||
if (!this.conexao.isClosed())
|
||||
this.conexao.close();
|
||||
closeConnection();
|
||||
}
|
||||
|
||||
return conteudo;
|
||||
|
@ -154,4 +145,15 @@ public abstract class Relatorio {
|
|||
this.nomeSubReporte = nomeSubReporte;
|
||||
}
|
||||
|
||||
public void closeConnection() {
|
||||
try {
|
||||
if(getConexao() != null && !getConexao().isClosed()) {
|
||||
getConexao().close();
|
||||
log.info("Conexão relatorio fechada");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Erro ao fechar a conexion", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue