public int generatePrestamosPorAlumno(int nroLegajo){
        String qry = "SELECT alumnos.nroLegajo, alumnos.Nombre, alumnos.Apellido, prestamos.codRecurso, prestamos.fechaPres"
                + ", prestamos.fechaPrevDevo, prestamos.fechaDevo "
                + " FROM prestamos JOIN alumnos ON prestamos.nroLegajo = alumnos.nroLegajo";
        
        if (nroLegajo != -1) qry += " WHERE alumnos.nroLegajo = " + nroLegajo;
        
        ResultSet rs = null;
        
        PrintWriter writer = null;
        try {
            writer = new PrintWriter("prestamosPorAlumno_"+ ((nroLegajo != -1) ? "legajo_" + nroLegajo : "todos") +".txt", "UTF-8");
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Modelo.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(Modelo.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        writer.println("Prestamos por alumno");
        writer.println("------------------------------");
        
        this.openDBConnection();
        try {
            rs = this.executeQuery(qry);
            
            String lastLegajo = "";
            
            while (rs.next()) {
                
                if (!lastLegajo.equals(rs.getString(1))){
                    writer.println("Nro legajo: " + rs.getString(1));
                    writer.println("Nombre: " + rs.getString(2));
                    writer.println("Apellido: " + rs.getString(3));
                    writer.println("------------------------------");
                    lastLegajo = rs.getString(1);
                }
                
                writer.println("---Prestamo---");
                writer.println("Cod Recurso: " + rs.getString(4));
                writer.println("Fecha Prestado: " + rs.getString(5));
                writer.println("Fecha Prevista de Devolución: " + rs.getString(6));
                writer.println("Fecha de devolución: " + rs.getString(5));
                writer.println("------------------------------");
            }
            
        } catch (Exception ex) {
            Logger.getLogger(Modelo.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            if (rs != null) {
                rs.close();
            }
        } catch (Exception ex) {
            Logger.getLogger(Modelo.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        writer.close();
        this.closeDBConnection();
        return 1;
    }