1

I need to open a command prompt & execute ij.bat, which will take me to another prompt, where I can give command to connect to DB & later different sql statements. I was able to execute ij.bat from the java program like

Process process = Runtime.getRuntime().exec("D:\\ij.bat");

But how to give the furthur set of commands through the java program?

1
  • I think you may try Robot to do this. To give command on opened command prompt. Commented May 12, 2015 at 7:20

2 Answers 2

0

You can use this exec public Process exec(String command) throws IOException

Also visit This Link

Sign up to request clarification or add additional context in comments.

3 Comments

My Scenario is cmd> ij.bat ij> connect '..\db\mall'; ij> select * from users;
Please visit the link in my answer
I cheked that. It has the details on how to read the output one command executed
0

Instead of trying to run ij.bat, and feed it commands to run and parse the output, just have your program use the ij class, and its runScript method: http://db.apache.org/derby/docs/10.11/publishedapi/org/apache/derby/tools/ij.html#runScript-java.sql.Connection-java.io.InputStream-java.lang.String-java.io.OutputStream-java.lang.String-

Then you don't have to spawn a separate process, but can just keep everything in pure Java in your program itself.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.