Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package application;
- import java.io.File;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import javafx.stage.Stage;
- public class MissingDocuments extends Stage {
- public MissingDocuments(Stage prev) {
- // TODO Auto-generated constructor stub.
- Stage current = this;
- try {
- setAttributes(current);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- private void setAttributes(Stage current) throws SQLException {
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/company?useSSL=false","root", "admin");
- String select ="select distinct patientID,serviceID,providerID from patientServiceProvider ";
- PreparedStatement searchStmt = conn.prepareStatement(select);
- ResultSet result=searchStmt.executeQuery();
- while( result.next()) {
- int ID=result.getInt("patientID");
- int numberOfFoundedReports=0;
- String CoID=getName("patient", "ID", "CoID", ID);
- System.out.println(CoID);
- String path ="D:\\رؤية\\"+CoID+"\\document";
- File providerFile= new File(path);
- if(providerFile.exists()) {
- numberOfFoundedReports=countNumberOfFiles(path);
- }
- if(numberOfFoundedReports==0) {
- System.out.println("patient with CoID = "+CoID +" has No documents" );
- }
- }
- }
- private String getName(String table,String conditon,String nameColumn,int id) throws SQLException {
- String name=null;
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/company?useSSL=false","root", "admin");
- String search="select * from "+table+" where "+conditon+" = ?";
- PreparedStatement searchStmt = conn.prepareStatement(search);
- searchStmt.setInt(1, id);
- ResultSet result=searchStmt.executeQuery();
- while( result.next()) {
- name=result.getString(nameColumn);
- }
- conn.close();
- return name;
- }
- private int countNumberOfFiles(String dirPath) {
- return new File(dirPath).listFiles().length;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement