简体   繁体   English

从Java程序执行包含SQL Plus命令的Shell脚本

[英]Executing Shell script which contains SQL Plus commands from Java Program

I have Shell script which executes properly when I run it manually. 我有Shell脚本,当我手动运行它时,它可以正确执行。 But I run the shell script through java program, the shell program runs, but it does not update the table and no error also is thrown. 但是我通过java程序运行了shell脚本,shell程序运行了,但是它不更新表,也没有引发错误。 Below contains the details of my shell script and link to java program. 以下包含我的Shell脚本的详细信息以及指向Java程序的链接。

Shell Script- Shell脚本-

echo "started the script execution"
 echo "
            BEGIN
                update <<table_name>> set name='abc';
                commit;
           END;
          /
 "|  sqlplus -s $MD_DB_USER_NAME/$MD_DB_PASS@$MD_DB_SERVER
echo "After executing the update statement"

Java Program from which I'm calling shell scipt: 我从中调用shell scipt的Java程序:
http://www.codesandscripts.com/2014/10/java-program-to-execute-shell-scripts-on-remote-server.html . http://www.codesandscripts.com/2014/10/java-program-to-execute-shell-scripts-on-remote-server.html

I think program is with connection to database. 我认为程序与数据库连接有关。 Can anyone tell me what it might be 谁能告诉我这可能是什么

Thanks for the above answers. 感谢您以上的答案。 My answer to my question is mentioned below- 我对我的问题的回答如下:

Before running through shell script, I was loading a profile file which contained all my DB details etc. So it was working properly. 在运行Shell脚本之前,我正在加载一个配置文件,其中包含我所有的数据库详细信息,等等。 But when I was running through java program, profile file was not loaded. 但是,当我通过Java程序运行时,未加载配置文件。 So in 1st line of my shell script I had to add source "profile file path". 因此,在我的shell脚本的第一行中,我必须添加源“配置文件路径”。 Now its working properly. 现在其正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM