简体   繁体   English

如何在不使用JDBC的情况下从Java运行.sql文件?

[英]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.

相关问题 如何在没有 iBatis 的情况下在 JDBC 中运行 SQL 脚本? - How to run SQL script in JDBC without iBatis? java-如何在不使用JDBC的情况下从数据库检索结果集? - java- how to retrieve resultset from database without using JDBC? 我们如何从Java代码更改exe文件的兼容模式并运行它 - how can we change a compatibilty mode of exe file from java code and run it 如何使用java jdbc连接到SQL Server并运行SQL Agent Job? - How to connect to sql server using java jdbc and run sql agent job? 如何使用 java 运行 Oracle.sql 文件 - how to run Oracle .sql file using java 如何在没有 @Query 的情况下使用 Spring Data JDBC 运行自定义 SQL? - How can I run custom SQL with Spring Data JDBC without @Query? 如何使用JDBC从Java连接到Access数据库? - How can I connect to an Access database from Java using JDBC? 如何在没有JDBC 4.2驱动程序的情况下从java.sql.Timestamp获取java.time对象? - How to get a java.time object from a java.sql.Timestamp without a JDBC 4.2 driver? 我们如何在不使用硒的情况下从 Java 代码点击网页? - how can we click on webpage from java code without using selenium? 我们如何使用 Java SDK 从 S3 存储桶下载没有文件夹的多个文件 - How can we download multiple files without folder from S3 bucket using Java SDK
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM