Vibha
Vibha

Reputation: 1109

Calling MongoImport From Java

I have written a .bat file (as I am testing on Windows for now):-

echo Program Starts mongoimport.exe --host 127.0.0.1 -d myDB -c things --type csv --file
D:\MOCK_DATA.csv --fields id,Name.f_name,Name.l_name,email,gender echo Program Ends

Following is the Java Console output: echo Program Starts Program Starts mongoimport.exe --host 127.0.0.1 -d myDB -c things --type csv --file D:\MOCK_DATA.csv --fields id,Name.f_name,Name.l_name,email,gender echo Program Ends Program Ends

Upvotes: 0

Views: 1062

Answers (1)

Vibha
Vibha

Reputation: 1109

I found the solution to the problem. Following lines helped in identifying the error:-
pb.redirectErrorStream(true);
pb.redirectOutput(new File("D:\\output.txt"));

The issue was that I didn't set the 'directory' where .bat file commands will run.
pb.directory(new File("\\MongoDB\\Server\\3.2\\bin"));

Upvotes: 0

Related Questions