Olá pessoa, estou com uma dúvida, estou desenvolvendo um sistema, que irá chamar os jar´s através de .bat.
São vários jar´s para chamar, ele verifica se o processo do jar acabou e executa o proximo jar.
Gostaria de sabe se a forma que estou implementando está correta, ou está parecendo um ninho de gato rsrs!
Por favor pessoa, preciso saber da melhor maneira de programar em java estou começando a pegar o jeito da coisa e gostaria da ajuda de vc´s
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package planominutoslocal;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.JOptionPane;
/**
*
* @author e449045
*/
public class PlanoMinutosLocal {
private static String SDS = "\\";
private static Integer msg = null;
private static String dt_ciclo;
private static String dt_mes_ftra;
private static String dt_data;
private static String dt_corte;
private static PrintWriter arquivo;
public static void main(String[] args) throws ClassNotFoundException, SQLException, IOException, InterruptedException {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection connection = DriverManager.getConnection("jdbc:sqlserver:localhost:1433;databaseName=banco_bd", "usuario", "senha");
System.out.println("conectado");
PreparedStatement stmt = connection.prepareStatement("select top 1 * from status_minutos order by dt_processo desc");
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
msg = rs.getInt("dt_processo");//verifica a proxima data de processamento
System.out.println("Data de Processamento : " + msg);
}
String comando = "C:\\NetBeansProjects\\ps_BT_PLTA_ATIS_PQ_PLN\\ps_BT_PLTA_ATIS_PQ_PLN.bat";
try {
File file = new File("C:\\CTL_MINUTOS_LOCAL\\BtPlano\\ps_BT_PLTA_ATIS_PQ_PLN.txt");
Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + comando); //executa o sistema
//File file = new File("C:\\CTL_MINUTOS_LOCAL\\BtPlano\\ps_BT_PLTA_ATIS_PQ_PLN.txt");
while (!file.exists()) {
System.out.println("Aguardando 5 segundos...");
// Aguarde 5 segundos
Thread.sleep(5000);
file = new File("C:\\CTL_MINUTOS_LOCAL\\BtPlano\\ps_BT_PLTA_ATIS_PQ_PLN.txt");
}
System.out.println("ok");
} catch (IOException e) {
e.printStackTrace();
}
String comando2 = "C:\\NetBeansProjects\\ps_BT_PLTA_ATIS_PQ_SRV\\ps_BT_PLTA_ATIS_PQ_SRV.bat";
try {
File file = new File("C:\\CTL_MINUTOS_LOCAL\\BtPlano\\ps_BT_PLTA_ATIS_PQ_SRV.txt");
Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + comando2); //executa o sistema
while (!file.exists()) {
System.out.println("Aguardando 5 segundos...");
// Aguarde 5 segundos
Thread.sleep(5000);
file = new File("C:\\CTL_MINUTOS_LOCAL\\BtPlano\\ps_BT_PLTA_ATIS_PQ_SRV.txt");
}
System.out.println("ok");
} catch (IOException e) {
e.printStackTrace();
}
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Erro : " + e);
}
}
}