Skip to content

Commit

Permalink
Mejora cierre conexión DB desde Jasper (#159)
Browse files Browse the repository at this point in the history
* Se cierra conexion JDBC de manera explicita para que no quede dangling ante una excepcion.
  • Loading branch information
lleonardis authored and enfoqueNativo committed Jun 29, 2023
1 parent fbc2e02 commit c5ef351
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions php/nucleo/lib/salidas/toba_vista_jasperreports.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,17 +323,25 @@ function completar_con_datos()
$this->parametros->put($jrxpath->PARAMETER_XML_DATA_DOCUMENT, $document);
$print = $this->jasper->fillReport($this->path_reporte, $this->parametros);
} else { //El conjunto de datos viene de una db o datasource
if (! isset($this->conexion)) {
$this->conexion = $this->instanciar_conexion_default();
}
if ($this->conexion instanceof toba_db) { //Si es una base toba, le configuro el schema
$con1 = $this->configurar_bd($this->conexion);
} else {
$con1 = $this->conexion;
}
//Creo el reporte finalmente con la conexion JDBC
$print = $this->jasper->fillReport($this->path_reporte, $this->parametros, $con1);
$con1->close();
try {
if (! isset($this->conexion)) {
$this->conexion = $this->instanciar_conexion_default();
}
if ($this->conexion instanceof toba_db) { //Si es una base toba, le configuro el schema
$con1 = $this->configurar_bd($this->conexion);
} else {
$con1 = $this->conexion;
}
//Creo el reporte finalmente con la conexion JDBC
$print = $this->jasper->fillReport($this->path_reporte, $this->parametros, $con1);
} catch (\Exception $e) {
toba::logger()->error('Error en la ejecución del reporte');
toba::logger()->error($e->getMessage());
throw $e;
} finally {
toba::logger()->debug("Jasper JDBC close Connection");
$con1->close();
}
}
$this->lista_jrprint[] = $print;
}
Expand Down Expand Up @@ -423,5 +431,4 @@ protected function cabecera_http( $longitud )
}


}
?>
}

0 comments on commit c5ef351

Please sign in to comment.