Install this theme
Load/Drop Jars to/from Oracle database using Ant

Oracle Client Package provides loadjava and dropjava tools to loading/dropping java classes / jars / resources to/from the Oracle database. 

Sometimes however it is necessary to run this functionality on the machine that doesn’t have Oracle Client package installed.

This post describes how to achieve this using Ant.

Note! This instruction is for Oracle 11g.

Prerequisites

From the machine having Oracle Client installed, copy ojdbc5.jar (typically located in $ORACLE_HOME/product/11.x/client_1/jdbc/lib) and aurora.zip (typically located in $ORACLE_HOME%/product/11.x/client_1/javavm/lib) to some folder accessible by your Ant script.

Below i’ll assume, that this 2 files are located in the same folder where the Ant script located.

Load Java Target

<target name="loadjava" description="target for deploying jars to the database">
	<java classname="oracle.aurora.server.tools.loadjava.LoadJavaMain" fork="true">
		<jvmarg value="-Xint" />
		<classpath>
			<pathelement location="aurora.zip" />
			<pathelement location="ojdbc5.jar" />
		</classpath>
		<arg line="-thin -user SCOTT/TIGER@DBHOST:1551:DBSID -resolve my-jar-to-upload.jar" />
	</java>
</target> 

This target will deploy my-jar-to-upload.jar file to the Oracle database identified by SCOTT/TIGER@DBHOST:1551:DBSID url.

Drop Java Target

<target name="dropjava" description="target for dropping jars from the database">
	<java classname="oracle.aurora.server.tools.loadjava.DropJavaMain" fork="true">
		<jvmarg value="-Xint" />
		<classpath>
			<pathelement location="aurora.zip" />
			<pathelement location="ojdbc5.jar" />
		</classpath>
		<arg line="-thin -user SCOTT/TIGER@DBHOST:1551:DBSID my-jar-to-upload.jar" />
	</java>
</target> 

This target will drop my-jar-to-upload.jar file from the Oracle database identified by SCOTT/TIGER@DBHOST:1551:DBSID url.

 
Blog comments powered by Disqus