private void readFilesFromDirectory(String path) { File directory = new File(path); tableRow = 0; if (directory.isDirectory()) { int count = 0; int row = 0; String name = ""; String pathSql = ""; for (File fi : directory.listFiles()) { if (fi.isFile()) { try { name = fi.getName(); pathSql = fi.getParentFile() + File.separator + "sql" + File.separator + name.split("\\.")[0] + ".sql"; jTable2.getModel().setValueAt(++count, row, 0); jTable2.getModel().setValueAt(name, row, 1); if (ioService.checkFileExist(pathSql)) { jTable2.getModel().setValueAt(true, row, 2); } tableRow++; row++; } catch (Exception e) { } } } } }
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: Boolean sqlStatus = false; Boolean selected = false; String fileName = ""; String parentPath = templatePath.getText() + File.separator; String sqlQuery = ""; for (int i = 0; i < tableRow; i++) { try { sqlStatus = (Boolean) jTable2.getModel().getValueAt(i, 2); selected = (Boolean) jTable2.getModel().getValueAt(i, 3); fileName = (String) jTable2.getModel().getValueAt(i, 1); if ((sqlStatus != null && sqlStatus == true) && (selected != null && selected == true)) { sqlQuery = ioService.readSql( parentPath + "sql" + File.separator + fileName.split("\\.")[0] + ".sql"); reconcileDo.doReconcile(parentPath + fileName, fileName, sqlQuery); } } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } } System.out.println("Finsih"); } // GEN-LAST:event_jButton1ActionPerformed