Tuesday, 12 May 2009

6-How to Develop Container-Managed-Relationships

FILE jndi.properties
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.factory.url.pkgs=weblogic.jndi.factories:weblogic.corba.j2ee.naming.url:weblogic.corba.client.naming
java.naming.provider.url=t3://localhost:7101
java.naming.security.principal=weblogic
java.naming.security.credentials=weblogic

FILE MySQL DDLs
CREATE TABLE `orders` (
`order_id` varchar(64) DEFAULT NULL,
`student_id` varchar(64) DEFAULT NULL,
`order_date` date DEFAULT NULL,
`status` varchar(64) DEFAULT NULL,
`amount` double(12,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


CREATE TABLE `orderlineitems` (
`orderLineItem_id` varchar(64) DEFAULT NULL,
`course_id` varchar(64) DEFAULT NULL,
`fee` double(12,2) DEFAULT NULL,
`order_id` varchar(64) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

FILE build.xml for ANT
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="EJB3 Tutorial" basedir="." default="deploy">

<property name="deploy.dir" value="C:/CMRentity/deploy" />
<property name="sourcedir" value="${basedir}/src"/>
<property name="targetdir" value="${basedir}/build"/>
<property name="librarydir" value="${basedir}/lib"/>

<path id="libraries">
<fileset dir="${librarydir}">
<include name="*.jar"/>
</fileset>
</path>

<target name="clean">
<delete dir="${targetdir}"/>
<mkdir dir="${targetdir}"/>
</target>

<target name="compile" depends="copy-resources">
<javac srcdir="${sourcedir}"
destdir="${targetdir}"
classpathref="libraries"
source="1.5"
debug="on">
<compilerarg value="-Xlint"/>
</javac>
</target>
<target name="copy-resources">
<copy todir="${targetdir}">
<fileset dir="${sourcedir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>

<target name="deploy" description="JARs the Task" depends="clean,copy-resources,compile">
<jar destfile="${deploy.dir}/CMRent.jar">
<metainf dir="${sourcedir}/META-INF" />
<fileset dir="${targetdir}">
<include name="**/*.class" />
</fileset>
</jar>
</target>

<target name="undeploy" description="Undeploy jar from server">
<delete file="${deploy.dir}/CMRent.jar" />
</target>

<target name="run" depends="compile">
<java classname="Client" classpathref="libraries">
<classpath path="${targetdir}"/>
<jvmarg value="-Djava.library.path=./lib"/>
</java>
</target>
</project>

Please refer to
http://tekne-techne.blogspot.com/2009/05/5-how-to-develop-container-managed.html
for the WLST Data source definition commands.
You can also find the FILE WebLogic Default Server config file and its –jdbc.xml extention
there.

For deployment to WebLogic:http://tekne-techne.blogspot.com/2009/05/6-how-to-develop-container-managed.html