cmd - Psql script not committing when executed from Java -


i have .bat file executes psql command import sql script file. when execute .bat file windows command line, executes correctly. when call .bat file java (with processbuilder), script doesn't end. i'm not getting errors, not in inputstream, errorstream not in db (postgresql) log.

arraylist<string> cmdargs2 = new arraylist<string>();         cmdargs2.add("sql2dbs.bat");           processbuilder pb2 = new processbuilder(cmdargs2);         logger.info(pb2.command().tostring());          map<string, string> env = pb2.environment();         env.put("pgpassword", "user");          process p2 = pb2.start();          bufferedreader stderror2 = new bufferedreader(new inputstreamreader(p2.geterrorstream()));         string s;         while ((s = stderror2.readline()) != null) {             logger.info(s);         }          bufferedreader stdin = new bufferedreader(new inputstreamreader(p2.getinputstream()));         while ((s = stdin.readline()) != null) {             logger.info(s);         }          p2.waitfor(); 

the sql script long that's why i'm not adding it. script have commit statement @ bottom.

any ideas? thanks,

don't run batch scripts using psql import data database. psql made interactive use, not (ab)used api. can directly in java via jdbc, see instance here or here. using jdbc give far better control , debugging options compared shelling out.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -