Run SQLPLUS with the exec-maven-plugin

The Exec Maven Plugin enables the execution of applications/programs from Java.

Here is an example on how to run Oracle SQLPLUS

<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>-->
     /oracle/product/10.1.3.1/OracleAS_1/bin/sqlplus
     <!-- where the SQL script is run from -->
     <workingDirectory>C:\SQL</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@db_tns</argument>
       <argument>createTables.sql</argument>
     </arguments>
   </configuration>
 </plugin>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: