I am doing coding in jsp. I have generated pdf using itext. And trying to save the document into database(mysql).
String filename="patient.pdf";
response.setContentType("application/pdf");
Document document = new Document();
PdfWriter pd= PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
document.addTitle("Dentistree");
document.add(new Paragraph("Hello,"+"\n\t"+"Thanks for making an appointment to Dentistree"+"\n\t"+"You have provided case history for your appointment. Here are the details of the appointment\n\t"+"List of the diseases that you are suffering through are as follows:"+di+"\n\n\nAre you pregnant?\t"+pregnant+"\n\n\nAre nursing a child?\t"+nursing+"\n\n\nDo you chew pan-masala?\t"+pan+"\n\n\nDo you smoke?\t"+smoke+"\n\n\nAllergic?\t"+all+"List of the medicines:"+medicines));
document.close();
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dentistree","root", "tiger");
String str="insert into appointment(email,pdf) values(?,?)";
PreparedStatement st = con.prepareStatement(str);
st.setString(1, mail);
st.setBlob(2,pd);
New to java coding. Please help