[英]How can we run .sql file from java without using JDBC?
I want to run a .sql file from java without using jdbc on windows 7. I am trying with java runtime class which executes the system commands. 我想从Windows运行.sql文件而不在Windows 7上使用jdbc。我正在尝试执行系统命令的java运行时类。 But my java is running with only user privileges and the command needs Administrator privileges.
但是我的Java仅以用户特权运行,并且该命令需要管理员特权。 The command that am using to run is "sqlplus /nolog @sqlscript.sql".
用于运行的命令是“ sqlplus / nolog @ sqlscript.sql”。
You need either JDBC, or a 3rd party software+sufficient rights. 您需要JDBC或第三方软件+足够的权限。
No other way. 别无退路。 (If we don't count low-level DB access, which would be an overkill)
(如果我们不算低级数据库访问,那将是一个过大的杀伤力)
I was able to do it by installing oracle client as the logged in user(We need to hold the shift key and right click on the exe and select Run as different user). 我可以通过以登录用户身份安装oracle客户端来做到这一点(我们需要按住Shift键并右键单击exe,然后选择“以其他用户身份运行”)。 Also we need to set oracle home in non primary partition of the hard diski.e., not where OS is installed.
另外,我们需要在硬盘的非主分区中设置oracle home,即不在安装OS的位置。 After doing this if i pass a command like "sqlplus /nolog @test.sql" to the Java Runtime class, it executes the script.
完成此操作后,如果我将“ sqlplus / nolog @ test.sql”之类的命令传递给Java Runtime类,它将执行脚本。 This works in only win 7 Ultimate and above.
仅在赢取7 Ultimate和更高版本时有效。 Win 7 Home and starter editions does not support this.
Win 7 Home和简化版不支持此功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.