0

i have to open cmd.exe from java and then open sqlplus.exe in the same window, but i can't. what i can do is open cmd but i'm unable to use it, for the sqlplus.exe it seems like its opening a different instance of cmd.exe and i can see the welcome msg from sqlplus in netbeans java terminal but unable to make querys.

And here's the code i'm using

public void construirJob(String nombre,Fecha fecha,String direccionSQL){
    try {
         command[0] = "cmd";
         command[1] = "/c";
         command[2] = "start cmd.exe && cd C:/oraclexe/app/oracle/product/11.2.0/server/bin && dir && sqlplus.exe"
           + " && @"+direccionSQL+" && connect /as sysdba; && select * from v$tablespace;";
        JobDetail job = JobBuilder.newJob(HelloJob.class)
                .withIdentity(nombre+"JOB", "group1").build();

        String schedule=fecha.segundos+" "+fecha.minutos+" "+fecha.hora+" "+"*"+" "+"*"+" "+fecha.dia;
        Trigger trigger = TriggerBuilder
                .newTrigger()
                .withIdentity(nombre+"trigger", "group1")
                .withSchedule(
                        //CronScheduleBuilder.cronSchedule("0/10 * * * * ?"))
                        CronScheduleBuilder.cronSchedule(schedule))
                .build();

        //schedule it
        Scheduler scheduler = new StdSchedulerFactory().getScheduler();
        scheduler.start();
        scheduler.scheduleJob(job, trigger);
    } catch (SchedulerException ex) {
        Logger.getLogger(CronTriggerExample.class.getName()).log(Level.SEVERE, null, ex);
    }
}
MaynorSong
  • 630
  • 7
  • 15

1 Answers1

0

I would take a look at apache commons exec library. http://commons.apache.org/proper/commons-exec/

There are also Turorials available on how to use this library: http://commons.apache.org/proper/commons-exec/tutorial.html

angabriel
  • 4,979
  • 2
  • 35
  • 37