Guest User

Untitled

a guest
Nov 25th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. UniqueID FilePath Status
  2. 1 C:Folder1abc.pdf Active
  3. 2 C:Folder1def.pdf Active
  4. 3 C:Folder1efg.pdf Error
  5.  
  6. public void doScan_DB() throws Exception {
  7.  
  8. try {
  9. Properties props = new Properties();
  10.  
  11.  
  12. InputStream in = getClass().getResourceAsStream("/db.properties");
  13.  
  14. props.load(in);
  15. in.close();
  16.  
  17.  
  18. String driver = props.getProperty("jdbc.driver");
  19. if (driver != null) {
  20. Class.forName(driver);
  21.  
  22. }
  23.  
  24. String url = props.getProperty("jdbc.url");
  25. String username = props.getProperty("jdbc.username");
  26. String password = props.getProperty("jdbc.password");
  27.  
  28. Connection con = DriverManager.getConnection(url, username, password);
  29. Statement statement = con.createStatement();
  30. ResultSet rs = statement.executeQuery("select * from filequeue where Status='Active'");
  31.  
  32. while (rs.next()) {
  33.  
  34. // while running the process, update status : Processing
  35. updateProcess_DB();
  36.  
  37. // get the filepath of the PDF document
  38. String path1 = rs.getString(2);
  39. MysqlAccessIndex conn = new MysqlAccessIndex();
  40. conn.doScan(path1);
  41. // After completing the process, update status: Complete
  42. // Should call some method
  43. }
  44. }catch(SQLException | IOException e){
  45. e.printStackTrace();
  46.  
  47. }
  48.  
  49. }
  50.  
  51. public void updateProcess_DB(){
  52.  
  53. try{
  54.  
  55. Properties props = new Properties();
  56.  
  57.  
  58. InputStream in = getClass().getResourceAsStream("/db.properties");
  59.  
  60. props.load(in);
  61. in.close();
  62.  
  63.  
  64. String driver = props.getProperty("jdbc.driver");
  65. if (driver != null) {
  66. Class.forName(driver);
  67.  
  68. }
  69.  
  70. String url = props.getProperty("jdbc.url");
  71. String username = props.getProperty("jdbc.username");
  72. String password = props.getProperty("jdbc.password");
  73.  
  74. Connection con = DriverManager.getConnection(url, username, password);
  75. Statement statement = con.createStatement();
  76. ResultSet rs = statement.executeQuery("update filequeue SET STATUS ='Proccessing' where STATUS ='Active' ");
  77.  
  78. while(rs.next()){
  79.  
  80.  
  81.  
  82. }
  83.  
  84.  
  85. }catch(Exception e){
  86.  
  87.  
  88.  
  89.  
  90.  
  91. }
  92.  
  93.  
  94.  
  95. }
Add Comment
Please, Sign In to add comment