<docbook><section><title>JDBCAppServerJbosLinux</title><para> </para><title> Using UDA with JBoss 4.0.3 (Linux) </title> Using UDA with JBoss 4.0.3 (Linux) 
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Required components </bridgehead>
<para>You will need to download the following components</para><itemizedlist mark="bullet" spacing="compact"><listitem> JBoss - <ulink url="http://www.jboss.com">download</ulink> </listitem>
<listitem> JDK - <ulink url="http://java.sun.com">download</ulink> </listitem>
<listitem> opltest.war Web Application - <ulink url="http://wiki.usnet.private:8791/twiki/pub/Main/UDATomcatLinux/opltest.war|download">http://wiki.usnet.private:8791/twiki/pub/Main/UDATomcatLinux/opltest.war|download</ulink> </listitem>
<listitem> <ulink url="OpenLink">OpenLink</ulink> jar file - one of these, appropriate to the selected JDK/JRE - 
<table><title /><tgroup><thead /><tbody>
<row><entry>  *JDK/JRE/JVM*  </entry><entry>  *<ulink url="OpenLink">OpenLink</ulink> JDBC Driver*  </entry></row>
<row><entry>  1.1  </entry><entry>  <ulink url="http://www.openlinksw.com/|opljdbc.jar">http://www.openlinksw.com/|opljdbc.jar</ulink>  </entry></row>
<row><entry>  1.2 or 1.3  </entry><entry>  <ulink url="http://www.openlinksw.com/|opljdbc2.jar">http://www.openlinksw.com/|opljdbc2.jar</ulink>  </entry></row>
<row><entry>  1.4 or 1.5  </entry><entry>  <ulink url="http://www.openlinksw.com/|opljdbc3.jar">http://www.openlinksw.com/|opljdbc3.jar</ulink>  </entry></row>
<row><entry>  1.6  </entry><entry>  <ulink url="http://www.openlinksw.com/|opljdbc4.jar">http://www.openlinksw.com/|opljdbc4.jar</ulink>  </entry></row>
<row><entry>  1.7  </entry><entry>  <ulink url="http://www.openlinksw.com/|opljdbc4_1.jar">http://www.openlinksw.com/|opljdbc4_1.jar</ulink>  </entry></row>
<row><entry>  1.8  </entry><entry>  <ulink url="http://www.openlinksw.com/|opljdbc4_2.jar">http://www.openlinksw.com/|opljdbc4_2.jar</ulink>  </entry></row>
</tbody></tgroup></table>
</listitem>
</itemizedlist><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Install JDK </bridgehead>
<para>Install the JDK by running the *.bin, which automatically extracts the JDK.</para><para>NOTE: You may need to set the execute permission on the bin file before it can be executed.</para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Set Environment Variables </bridgehead>
<para>The following environment variables must be set -- </para><programlisting>  export JAVA_HOME=/usr/java/jre1.5.0_05
  export PATH=$PATH:/usr/java/jdk1.5.0_05/bin
</programlisting><para> The simplest way is to add these to your -- <computeroutput>~/.bash_profile=</computeroutput> (or similar, depending on <emphasis><emphasis>$SHELL</emphasis></emphasis>) to ensure they are set every time you log in.</para><para>NOTE: Paths to your Java installation will most likely differ!</para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Install JBoss </bridgehead>
<para>Installing JBoss by running gunzip and tar against the downloaded <computeroutput>*.tar.gz</computeroutput> file which will extract the archive into the current working directory.
</para><programlisting>gunzip *.tar.gz
tar -xvf *.tar
</programlisting><para> The root install directory of JBoss will be known as; <computeroutput>$JBOSS_DIST</computeroutput></para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Starting JBoss </bridgehead>
<para>Start JBoss using the command -- </para><programlisting>$JBOSS_DIST/bin/run.sh
</programlisting><para> Browse to the following url to verify that JBoss is up and running -- </para><programlisting>http://tomcat_server:8080
</programlisting><para> NOTE: JBoss may take several minutes to start.</para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Install <ulink url="OpenLink">OpenLink</ulink> jar files </bridgehead>
<para>Copy the <computeroutput>.jar</computeroutput> file chosen for your JDK/JVM/JRE into the directory -- <computeroutput>$JBOSS_DIST/server/default/lib</computeroutput></para><para>Stop and restart JBoss with the commands -- <computeroutput>Control-C will stop JBoss$JBOSS_DIST/bin/run.sh</computeroutput></para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Create the data sources file </bridgehead>
<para>JBoss requires a special file to declare the data sources.</para><para>Create a new file -- <computeroutput>$JBOSS_DIST/server/default/deploy/opltest-ds.xml</computeroutput></para><para>to include the following data sources --</para><programlisting>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;!--  Datasource config for OpenLink --&gt;

&lt;local-tx-datasource&gt;
  &lt;jndi-name&gt;jdbc/o32opljdbc1&lt;/jndi-name&gt;
  &lt;connection-url&gt;jdbc:openlink://192.168.0.150:5000/SVT=Odbc/Database=sqlserver/UID=sa/PWD=sa&lt;/connection-url&gt;
  &lt;driver-class&gt;openlink.jdbc.Driver&lt;/driver-class&gt;
  &lt;user-name&gt;sa&lt;/user-name&gt;
  &lt;password&gt;sa&lt;/password&gt;
&lt;/local-tx-datasource&gt;

&lt;local-tx-datasource&gt;
  &lt;jndi-name&gt;jdbc/m32opljdbc1&lt;/jndi-name&gt;
  &lt;connection-url&gt;jdbc:openlink://192.168.0.150:5000/SVT=SQLServer 2000/Database=Northwind/options=-H 192.168.0.150/UID=sa/PWD=sa&lt;/connection-url&gt;
  &lt;driver-class&gt;openlink.jdbc.Driver&lt;/driver-class&gt;
  &lt;user-name&gt;sa&lt;/user-name&gt;
  &lt;password&gt;sa&lt;/password&gt;
&lt;/local-tx-datasource&gt;

&lt;local-tx-datasource&gt;
  &lt;jndi-name&gt;jdbc/o32opljdbc2&lt;/jndi-name&gt;
  &lt;connection-url&gt;jdbc:openlink://192.168.0.150:5000/SVT=Odbc/Database=sqlserver/UID=sa/PWD=sa&lt;/connection-url&gt;
  &lt;driver-class&gt;openlink.jdbc2.Driver&lt;/driver-class&gt;
  &lt;user-name&gt;sa&lt;/user-name&gt;
  &lt;password&gt;sa&lt;/password&gt;
&lt;/local-tx-datasource&gt;

&lt;local-tx-datasource&gt;
  &lt;jndi-name&gt;jdbc/m32opljdbc2&lt;/jndi-name&gt;
  &lt;connection-url&gt;jdbc:openlink://192.168.0.150:5000/SVT=SQLServer 2000/Database=Northwind/options=-H 192.168.0.150/UID=sa/PWD=sa&lt;/connection-url&gt;
  &lt;driver-class&gt;openlink.jdbc2.Driver&lt;/driver-class&gt;
  &lt;user-name&gt;sa&lt;/user-name&gt;
  &lt;password&gt;sa&lt;/password&gt;
&lt;/local-tx-datasource&gt;

&lt;local-tx-datasource&gt;
  &lt;jndi-name&gt;jdbc/o32opljdbc3&lt;/jndi-name&gt;
  &lt;connection-url&gt;jdbc:openlink://192.168.0.150:5000/SVT=Odbc/Database=sqlserver/UID=sa/PWD=sa&lt;/connection-url&gt;
  &lt;driver-class&gt;openlink.jdbc3.Driver&lt;/driver-class&gt;
  &lt;user-name&gt;sa&lt;/user-name&gt;
  &lt;password&gt;sa&lt;/password&gt;
&lt;/local-tx-datasource&gt;

&lt;local-tx-datasource&gt;
  &lt;jndi-name&gt;jdbc/m32opljdbc3&lt;/jndi-name&gt;
  &lt;connection-url&gt;jdbc:openlink://192.168.0.150:5000/SVT=SQLServer 2000/Database=Northwind/options=-H 192.168.0.150/UID=sa/PWD=sa&lt;/connection-url&gt;
  &lt;driver-class&gt;openlink.jdbc3.Driver&lt;/driver-class&gt;
  &lt;user-name&gt;sa&lt;/user-name&gt;
  &lt;password&gt;sa&lt;/password&gt;
&lt;/local-tx-datasource&gt;

&lt;/datasources&gt;
</programlisting><para> NOTE: You will need to amend URLs, usernames and passwords as appropriate.</para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Prepare the Web Application </bridgehead>
<para>Demonstrating how to build and deploy a Web application from the beginning is beyond the scope of this short tutorial so what follows is a quick method of altering the JDBC URLs and SQL statements in an existing Web application.</para><para>NOTE: Be careful when moving .war files about using Internet Explorer.
 Sometimes they will be renamed to .zip by Internet Explorer.</para><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Rename the .war file to .zip </bridgehead>
<para>Rename - <computeroutput>opltest.war</computeroutput> -to- <computeroutput>opltest.zip</computeroutput></para><para>You will then be able to unzip the archive to get at the files inside it.
 (Some utilities can unzip the .war archive without renaming.) <computeroutput>unzip opltest.zip</computeroutput></para><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Edit JDBC URLs </bridgehead>
<para>Edit the driver class and the JDBC connection URL in the file -- <computeroutput>/META-INF/context.xml</computeroutput></para><para>NOTE: Ensure that the edited file is placed back into the archive.
<computeroutput>zip -r ../opltest *</computeroutput></para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Edit the SQL statement(s) </bridgehead>
<para>You will need to edit the SQL statement(s) in <emphasis>the following JSP files</emphasis> based on the chosen database determined by the JDBC URL in the file -- <computeroutput>/META-INF/context.xml</computeroutput></para><para>Edit the JSP files -- </para><programlisting>opljdbc.jsp
opljdbc2.jsp 
opljdbc3.jsp
</programlisting><para> There are two main areas of interest --</para><orderedlist spacing="compact"><listitem>The &lt;sql:query&gt; tag which select the datasource as defined in - <computeroutput>/META-INF/context.xml</computeroutput> which contains the SQL query itself --  <computeroutput>&lt;sql:query var=&quot;resultset&quot; dataSource=&quot;jdbc/opljdbc2&quot;&gt;		select SupplierID, CompanyName, ContactName, ContactTitle from Suppliers	&lt;/sql:query&gt;</computeroutput> 		 </listitem>
<listitem>The one or more ${row.column_name} constructs that output data as per the SQL query  <computeroutput>${row.SupplierID}${row.CompanyName} </computeroutput></listitem>
</orderedlist><para> NOTE: Ensure that the edited file is placed back into the archive.
<computeroutput>zip -r ../opltest *</computeroutput></para><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Rename the .zip file back to .war </bridgehead>
<para>Rename the file <computeroutput>opltest.zip</computeroutput> back to <computeroutput>opltest.war</computeroutput></para><para> </para><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Deploy opltest Web Application </bridgehead>
<para>Deploying on JBoss is simply a case of placing the Web application -- <computeroutput>opltest.war</computeroutput></para><para>into the following directory -- <computeroutput>$JBOSS_DIST/server/default/deploy</computeroutput></para><para>The newly deployed application is now available at the following URL -- <computeroutput>http://jboss_server:8080/opltest</computeroutput></para></section></docbook>