.matinc
.matinc
RRailway
Created by .matinc on 6/12/2023 in #✋|help
Jasreport unknow error
sorry xd, I'm Argentinean
12 replies
RRailway
Created by .matinc on 6/12/2023 in #✋|help
Jasreport unknow error
Finally this is the controller that creates the pdf files in the url.
12 replies
RRailway
Created by .matinc on 6/12/2023 in #✋|help
Jasreport unknow error
@PostMapping("/export-pdf") public String exportPdf(@RequestParam("cursoId") Long cursoId, @RequestParam("alumnoIds") List<Long> alumnoIds) throws JRException, FileNotFoundException, SQLException { crearRuta(cursoId); for (Long a : alumnoIds) { Connection connection = null; // Declarar la conexión fuera del bloque try-catch try { connection = dataSource.getConnection(); Map<String, Object> params = new HashMap<>(); params.put("p_ciclo_lectivo", 2023); params.put("p_curso", cursoId.intValue()); params.put("palumno", a.intValue()); String reportName = servletContext.getRealPath("/resources/BoletinCalificaciones.jrxml"); String carpetaRelativa = "Boletin/Curso/"; String rutaCarpeta = carpetaRelativa + cursoRepositorio.findById(cursoId).get().getCurso() + "" + cursoRepositorio.findById(cursoId).get().getDivision() + "" + reemplazarEspacios(cursoRepositorio.findById(cursoId).get().getOrientacion()) + "" + cursoRepositorio.findById(cursoId).get().getTurno() + "/bol_" + alumnoRepositorio.findById(a).get().getDni() + ".pdf"; String rutaAbsoluta = servletContext.getRealPath(rutaCarpeta); BoletinReportGenerator.exportToPdf(connection, reportName, rutaAbsoluta, params); } catch (SQLException e) { System.out.println(e.getMessage()); } finally { if (connection != null) { try { connection.close(); } catch (SQLException e) { System.out.println("Error al cerrar la conexión: " + e.getMessage()); } } } } return "redirect:/boletin/curso-boletin?id=" + cursoId; }.
12 replies
RRailway
Created by .matinc on 6/12/2023 in #✋|help
Jasreport unknow error
public void crearCarpeta(String ruta) { File carpeta = new File(ruta); if (!carpeta.exists()) { if (carpeta.mkdirs()) { System.out.println("Carpeta creada correctamente en: " + carpeta.getAbsolutePath()); } else { System.out.println("Error al crear la carpeta."); } } else { System.out.println("La carpeta ya existe en: " + carpeta.getAbsolutePath()); } }. This is the function that receives the url and creates the folder if everything goes well
12 replies
RRailway
Created by .matinc on 6/12/2023 in #✋|help
Jasreport unknow error
public void crearRuta(Long id) throws FileNotFoundException { String carpetaRelativa = "Boletin/Curso/"; String rutaCarpeta = carpetaRelativa + cursoRepositorio.findById(id).get().getCurso() + "" + cursoRepositorio.findById(id).get().getDivision() + "" + reemplazarEspacios(cursoRepositorio.findById(id).get().getOrientacion()) + "_" + cursoRepositorio.findById(id).get().getTurno(); String rutaAbsoluta = servletContext.getRealPath(rutaCarpeta); crearCarpeta(rutaAbsoluta); }. This is the controller that creates the path for the folder where I want the pdf reports to be saved (if it's not already created)
12 replies
RRailway
Created by .matinc on 6/12/2023 in #✋|help
Jasreport unknow error
49a649e6-18bd-49d5-8ff9-229140c455cb project id
12 replies