Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UniqueID FilePath Status
- 1 C:Folder1abc.pdf Active
- 2 C:Folder1def.pdf Active
- 3 C:Folder1efg.pdf Error
- public void doScan_DB() throws Exception {
- try {
- Properties props = new Properties();
- InputStream in = getClass().getResourceAsStream("/db.properties");
- props.load(in);
- in.close();
- String driver = props.getProperty("jdbc.driver");
- if (driver != null) {
- Class.forName(driver);
- }
- String url = props.getProperty("jdbc.url");
- String username = props.getProperty("jdbc.username");
- String password = props.getProperty("jdbc.password");
- Connection con = DriverManager.getConnection(url, username, password);
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("select * from filequeue where Status='Active'");
- while (rs.next()) {
- // while running the process, update status : Processing
- updateProcess_DB();
- // get the filepath of the PDF document
- String path1 = rs.getString(2);
- MysqlAccessIndex conn = new MysqlAccessIndex();
- conn.doScan(path1);
- // After completing the process, update status: Complete
- // Should call some method
- }
- }catch(SQLException | IOException e){
- e.printStackTrace();
- }
- }
- public void updateProcess_DB(){
- try{
- Properties props = new Properties();
- InputStream in = getClass().getResourceAsStream("/db.properties");
- props.load(in);
- in.close();
- String driver = props.getProperty("jdbc.driver");
- if (driver != null) {
- Class.forName(driver);
- }
- String url = props.getProperty("jdbc.url");
- String username = props.getProperty("jdbc.username");
- String password = props.getProperty("jdbc.password");
- Connection con = DriverManager.getConnection(url, username, password);
- Statement statement = con.createStatement();
- ResultSet rs = statement.executeQuery("update filequeue SET STATUS ='Proccessing' where STATUS ='Active' ");
- while(rs.next()){
- }
- }catch(Exception e){
- }
- }
Add Comment
Please, Sign In to add comment