How to save pdf file generated in spring mvc in to database directly after being generated..?
<p>This is my class for generating a pdf. It generates a pdf when I submit the form, but I could not figure out how to save it to the database.</p>

<pre><code>public class BookingPdf {

        private static String FILE = "D:/Hotels/pdf/";
        protected static Font font10;
        protected static Font font10b;
        protected static Font font12;
        protected static Font font12b;
        protected static Font font14;

        public static String generateBookingPDF(Booking booking) throws DocumentException, FileNotFoundException, IOException {
            Document document = new Document(PageSize.A4);
            String bookingname = booking.getFirstName() + " " + booking.getLastName();
            document.addHeader("HOTEL SWING", "Hotel Swing Booking confirmation");
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(FILE + "Booking" + " " + booking.getCustomer().getFirstName() + ".pdf "));
            writer.setViewerPreferences(PdfWriter.PageModeUseOC);
            writer.setPdfVersion(PdfWriter.VERSION_1_7);
            document.open();
            String html = htmlTemplate(booking);

            List unorderedList = new List(List.UNORDERED);
            unorderedList.add(new ListItem("Name       :" + booking.getFirstName() + " " + booking.getLastName()));
            unorderedList.add(new ListItem("Room  :" + booking.getRoom().getRoomNumber()));
            unorderedList.add(new ListItem("Total Price  :" + booking.getTotalPrice()));
            unorderedList.add(new ListItem("check in   :" + booking.getRoom().getRoomNumber()));
            unorderedList.add(new ListItem("Booking:" + booking.getbId()));

            document.add(unorderedList);
            document.close();
            return bookingname;

        }

        private static String htmlTemplate(Booking booking) {
            StringBuilder html = new StringBuilder();

            html.append("" + "&lt;h1&gt; Booking Confirmation&lt;/h1&gt;  ");
            return html.toString();

        }

        public BookingPdf(Booking booking) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        public BookingPdf() {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

    }
</code></pre>

<p>here is my controller class from where I want to save the pdf location and save it to the database</p>

<pre><code>@RequestMapping(value = "/save", method = RequestMethod.POST)
    public String save(@ModelAttribute("Booking") Booking booking, BindingResult result, HttpServletRequest request) throws SQLException, ParseException, DocumentException, IOException {
        Customer customer = customerService.getById(booking.getCustomer().getC_id());
        Room room = roomService.getById(booking.getRoom().getRo_id());
        long totalNights = (booking.getCheckoutDate().getTime() - booking.getCheckinDate().getTime()) / (24 * 60 * 60 * 1000);
        System.out.println(totalNights);
        booking.setTotalNights((int) totalNights);
        int totalPrice = (booking.getTotalNights() *  booking.getRoom().getRoomPrice());
        booking.setTotalPrice(totalPrice);
        System.out.println(totalPrice);
        System.out.println("check" + booking);

        try {
            booking.setCustomer(customer);
            booking.setRoom(room);
            if (booking.getbId() == 0) {
                bookingService.insert(booking);
                BookingPdf.generateBookingPDF(booking);

            } else 
               {
                bookingService.update(booking);
            }
        } catch (SQLException ex) {
        }
        return "redirect:";
</code></pre>