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 {
|
public ArrayDataSource(Relatorio relatorio) throws Exception {
|
||||||
this.relatorio = relatorio;
|
this.relatorio = relatorio;
|
||||||
this.dados = new ArrayList<Map<String, Object>>();
|
this.dados = new ArrayList<Map<String, Object>>();
|
||||||
this.initDados();
|
try {
|
||||||
|
this.initDados();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
if(this.relatorio != null) {
|
||||||
|
this.relatorio.closeConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
this.rowNum = -1;
|
this.rowNum = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,15 @@ public class DataSource implements IDataSource {
|
||||||
|
|
||||||
public DataSource(Relatorio relatorio) throws Exception {
|
public DataSource(Relatorio relatorio) throws Exception {
|
||||||
this.relatorio = relatorio;
|
this.relatorio = relatorio;
|
||||||
this.initDados();
|
try {
|
||||||
|
this.initDados();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
if(this.relatorio != null) {
|
||||||
|
this.relatorio.closeConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
this.rowNum = -1;
|
this.rowNum = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package com.rjconsultores.ventaboletos.relatorios.utilitarios;
|
package com.rjconsultores.ventaboletos.relatorios.utilitarios;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.relatorios.render.RenderRelatorioJasper;
|
import com.rjconsultores.ventaboletos.relatorios.render.RenderRelatorioJasper;
|
||||||
|
|
||||||
|
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bruno H. G. Gouvêa <bruno@rjconsultores.com.br>
|
* @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) {
|
public void setCustomDataSource(boolean closeConnection,IDataSource iDataSource) {
|
||||||
this.customDataSource = iDataSource;
|
this.customDataSource = iDataSource;
|
||||||
if (closeConnection){
|
if (closeConnection){
|
||||||
try {
|
closeConnection();
|
||||||
if (!this.conexao.isClosed())
|
|
||||||
this.conexao.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
log.error("Erro ao fechar a conexion", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,12 +120,9 @@ public abstract class Relatorio {
|
||||||
conteudo = this.render.render(saida);
|
conteudo = this.render.render(saida);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (!this.conexao.isClosed())
|
|
||||||
this.conexao.close();
|
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
if (!this.conexao.isClosed())
|
closeConnection();
|
||||||
this.conexao.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return conteudo;
|
return conteudo;
|
||||||
|
@ -153,5 +144,16 @@ public abstract class Relatorio {
|
||||||
public void setNomeSubReporte(String[] nomeSubReporte) {
|
public void setNomeSubReporte(String[] nomeSubReporte) {
|
||||||
this.nomeSubReporte = nomeSubReporte;
|
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