Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String url = "jdbc:mysql://localhost:3306/GlHSM";
- String user = "root"; //Username of database
- String pass1 = ""; //Password of database
- Connection conn = DriverManager.getConnection(url, user, pass1);
- Statement stmt = conn.createStatement();
- ResultSet query = stmt.executeQuery("select * from CardInformation");
- response.setContentType("application/pdf");
- Document PDFLogReport = new Document();
- PdfWriter.getInstance(PDFLogReport,response.getOutputStream());
- PDFLogReport.open();
- PDFLogReport.add(new Paragraph("Card Information: n"));
- PDFLogReport.add(new Paragraph(" "));
- PdfPTable LogTable = new PdfPTable(12);
- PdfPCell table_cell;
- table_cell = new PdfPCell(new Phrase("Index"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- table_cell = new PdfPCell(new Phrase("Card No"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- table_cell = new PdfPCell(new Phrase("PIN Block"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- table_cell = new PdfPCell(new Phrase("Card Expiry"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- table_cell = new PdfPCell(new Phrase("Issue Date"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- table_cell = new PdfPCell(new Phrase("PIN Retries"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- table_cell = new PdfPCell(new Phrase("BIO Retries"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- table_cell = new PdfPCell(new Phrase("Is Blocked"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- table_cell = new PdfPCell(new Phrase("Block Date Time"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- table_cell = new PdfPCell(new Phrase("Created By"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- table_cell = new PdfPCell(new Phrase("Date Created"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- table_cell = new PdfPCell(new Phrase("Card Type"));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- LogTable.setHeaderRows(1);
- while(query.next()){
- String fname = query.getString("Indx");
- table_cell = new PdfPCell(new Phrase(fname));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- String lname = query.getString("CardNo");
- table_cell = new PdfPCell(new Phrase(lname));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- String date = query.getString("PINBlock");
- table_cell = new PdfPCell(new Phrase(date));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- String gender = query.getString("CardExpiry");
- table_cell = new PdfPCell(new Phrase(gender));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- String gender2 = query.getString("IssueDate");
- table_cell = new PdfPCell(new Phrase(gender2));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- String pin = query.getString("PINRetries");
- table_cell = new PdfPCell(new Phrase(pin));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- String dob = query.getString("BIORetries");
- table_cell = new PdfPCell(new Phrase(dob));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- String con = query.getString("IsBlocked");
- table_cell = new PdfPCell(new Phrase(con));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- String cr = query.getString("BlockDateTime");
- table_cell = new PdfPCell(new Phrase(cr));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- String da = query.getString("CreatedBy");
- table_cell = new PdfPCell(new Phrase(da));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- String pan = query.getString("DateCreated");
- table_cell = new PdfPCell(new Phrase(pan));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- String cty = query.getString("CardType");
- table_cell = new PdfPCell(new Phrase(cty));
- table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
- LogTable.addCell(table_cell);
- }
- PDFLogReport.add(LogTable);
- PDFLogReport.close();
- query.close();
- stmt.close();
- conn.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement