Syntax
sqlplus username/password@ConnectIdentifier command
where:
- username is the database login name
- password is the password. If the password contains an ampersand, you can escape it like this \”my@Pwd\”
- identifier is a connect identifier
- command, generally @script.sql
Articles Related
How to start SQLPlus
Maven
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${maven_exec_plugin_version}</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>sqlplus</executable>
<!-- where the SQL script is run from -->
<workingDirectory>/Path</workingDirectory>
<!-- set env variables -->
<environmentVariables>
<ORACLE_HOME>/oracle/product/10.1.3.1/OracleAS_1</ORACLE_HOME>
<PATH>$PATH:$ORACLE_HOME/bin:$JAVA_HOME/bin</PATH>
<LD_LIBRARY_PATH>$LD_LIBRARY_PATH:$ORACLE_HOME/lib</LD_LIBRARY_PATH>
<PATH>$PATH:$ORACLE_HOME/bin</PATH>
</environmentVariables>
<!-- arguments to be passed to SQLPLUS -->
<arguments>
<argument>user/pwd@localhost:1521/ORCL</argument>
<argument>@release/RollbackAndInstallReleases.sql</argument>
</arguments>
</configuration>
</plugin>
Jenkins
sqlplus %SQL_USER%/\"%SQL_PWD%\"@localhost:1521/ORCL @execution.sql 2>&1 output.txt
where:
- %SQL_USER% and %SQL_PWD% are environment variable created by the Jenkins Credential Manager