Advertisement
Guest User

Untitled

a guest
Apr 20th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. String url = "jdbc:mysql://localhost:3306/GlHSM";
  2. String user = "root"; //Username of database
  3. String pass1 = ""; //Password of database
  4. Connection conn = DriverManager.getConnection(url, user, pass1);
  5. Statement stmt = conn.createStatement();
  6. ResultSet query = stmt.executeQuery("select * from CardInformation");
  7. response.setContentType("application/pdf");
  8. Document PDFLogReport = new Document();
  9. PdfWriter.getInstance(PDFLogReport,response.getOutputStream());
  10. PDFLogReport.open();
  11. PDFLogReport.add(new Paragraph("Card Information: n"));
  12. PDFLogReport.add(new Paragraph(" "));
  13. PdfPTable LogTable = new PdfPTable(12);
  14. PdfPCell table_cell;
  15. table_cell = new PdfPCell(new Phrase("Index"));
  16. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  17. LogTable.addCell(table_cell);
  18. table_cell = new PdfPCell(new Phrase("Card No"));
  19. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  20. LogTable.addCell(table_cell);
  21. table_cell = new PdfPCell(new Phrase("PIN Block"));
  22. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  23. LogTable.addCell(table_cell);
  24. table_cell = new PdfPCell(new Phrase("Card Expiry"));
  25. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  26. LogTable.addCell(table_cell);
  27. table_cell = new PdfPCell(new Phrase("Issue Date"));
  28. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  29. LogTable.addCell(table_cell);
  30. table_cell = new PdfPCell(new Phrase("PIN Retries"));
  31. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  32. LogTable.addCell(table_cell);
  33. table_cell = new PdfPCell(new Phrase("BIO Retries"));
  34. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  35. LogTable.addCell(table_cell);
  36. table_cell = new PdfPCell(new Phrase("Is Blocked"));
  37. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  38. LogTable.addCell(table_cell);
  39. table_cell = new PdfPCell(new Phrase("Block Date Time"));
  40. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  41. LogTable.addCell(table_cell);
  42. table_cell = new PdfPCell(new Phrase("Created By"));
  43. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  44. LogTable.addCell(table_cell);
  45. table_cell = new PdfPCell(new Phrase("Date Created"));
  46. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  47. LogTable.addCell(table_cell);
  48. table_cell = new PdfPCell(new Phrase("Card Type"));
  49. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  50. LogTable.addCell(table_cell);
  51. LogTable.setHeaderRows(1);
  52. while(query.next()){
  53. String fname = query.getString("Indx");
  54. table_cell = new PdfPCell(new Phrase(fname));
  55. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  56. LogTable.addCell(table_cell);
  57. String lname = query.getString("CardNo");
  58. table_cell = new PdfPCell(new Phrase(lname));
  59. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  60. LogTable.addCell(table_cell);
  61. String date = query.getString("PINBlock");
  62. table_cell = new PdfPCell(new Phrase(date));
  63. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  64. LogTable.addCell(table_cell);
  65. String gender = query.getString("CardExpiry");
  66. table_cell = new PdfPCell(new Phrase(gender));
  67. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  68. LogTable.addCell(table_cell);
  69. String gender2 = query.getString("IssueDate");
  70. table_cell = new PdfPCell(new Phrase(gender2));
  71. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  72. LogTable.addCell(table_cell);
  73. String pin = query.getString("PINRetries");
  74. table_cell = new PdfPCell(new Phrase(pin));
  75. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  76. LogTable.addCell(table_cell);
  77. String dob = query.getString("BIORetries");
  78. table_cell = new PdfPCell(new Phrase(dob));
  79. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  80. LogTable.addCell(table_cell);
  81. String con = query.getString("IsBlocked");
  82. table_cell = new PdfPCell(new Phrase(con));
  83. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  84. LogTable.addCell(table_cell);
  85. String cr = query.getString("BlockDateTime");
  86. table_cell = new PdfPCell(new Phrase(cr));
  87. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  88. LogTable.addCell(table_cell);
  89. String da = query.getString("CreatedBy");
  90. table_cell = new PdfPCell(new Phrase(da));
  91. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  92. LogTable.addCell(table_cell);
  93. String pan = query.getString("DateCreated");
  94. table_cell = new PdfPCell(new Phrase(pan));
  95. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  96. LogTable.addCell(table_cell);
  97. String cty = query.getString("CardType");
  98. table_cell = new PdfPCell(new Phrase(cty));
  99. table_cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  100. LogTable.addCell(table_cell);
  101. }
  102. PDFLogReport.add(LogTable);
  103. PDFLogReport.close();
  104. query.close();
  105. stmt.close();
  106. conn.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement