Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Starting

...

with

...

DAS

...

This

...

page

...

provides

...

links

...

to

...

DAS

...

samples

...

and

...

explains

...

a

...

simple

...

"how

...

to"

...

and

...

gives

...

step-by-step

...

instructions

...

to

...

check

...

one

...

of

...

the

...

DAS

...

features

...

-

...

ColumnConverter.

...

Other

...

DAS

...

features

...

can

...

be

...

tried

...

on

...

similar

...

lines.

...

Many

...

sample

...

examples

...

demonstrating

...

different

...

DAS

...

features

...

are

...

available

...

on

...

https://svn.apache.org/repos/asf/incubator/tuscany/java/das/samples

...

Image Added e.g.

...

  1. companyweb

...

  1. -

...

  1. tomcat

...

  1. based

...

  1. web

...

  1. sample

...

  1. customer

...

  1. -

...

  1. J2SE

...

  1. based

...

  1. standalone

...

  1. application

...

Check

...

readme

...

files

...

e.g.

...

For

...

companyweb

...

https://svn.apache.org/repos/asf/incubator/tuscany/java/das/samples/companyweb/readme.htm

...

Image Added
for

...

basic

...

steps

...

on

...

how

...

to

...

get

...

the

...

sample

...

running.

...

Once

...

the

...

sample

...

is

...

running,

...

parts

...

of

...

sample

...

can

...

be

...

modified

...

based

...

on

...

the

...

requirement

...

or

...

new

...

code

...

can

...

be

...

added

...

from-scratch.

...

Many

...

features

...

supported

...

by

...

DAS

...

are

...

listed

...

in

...

User

...

Guide

...

-

...

http://cwiki.apache.org/confluence/display/TUSCANY/RDB+DAS+-+User+GuideImage Added.

...

This

...

document

...

details

...

the

...

changes

...

needed

...

to

...

different

...

part

...

of

...

the

...

web

...

sample

...

(companyweb)

...

to

...

experiment

...

with

...

more

...

features

...

of

...

DAS

...

than

...

just

...

basic

...

CRUD.Let

...

us

...

take

...

example

...

of

...

checking

...

how

...

to

...

use

...

ColumnConverters.

...

For

...

details

...

on

...

feature

...

testing,

...

check

...

Tests

...

under

...

https://svn.apache.org/repos/asf/incubator/tuscany/java/das/rdb/src/test/

...

Image Added

  1. As a first step you need to implement Converter interface in a class to achieve the required
    column conversion. Check org.apache.tuscany.das.rdb.test.mappings.StringObfuscationConverter

...

  1. from

...

  1. the

...

  1. svn

...

  1. repository

...

  1. for

...

  1. example

...

  1. of

...

  1. converter.

...

  1. Make

...

  1. your

...

  1. converter

...

  1. class

...

  1. available

...

  1. in

...

  1. (Tomcat

...

  1. root)webapps/companyweb/WEB-INF/classes.

...

  1. DAS

...

  1. functions

...

  1. based

...

  1. on

...

  1. external

...

  1. Configuration,

...

  1. e.g.

...

  1. CompanyConfig.xml

...

  1. file

...

  1. in

...

  1. companyweb

...

  1. sample.

...

  1. The

...

  1. purpose

...

  1. of

...

  1. this

...

  1. Config

...

  1. file

...

  1. to

...

  1. supply

...

  1. information

...

  1. for

...

  1. DataSource

...

  1. connection,

...

  1. Commands

...

  1. (SQL)

...

  1. (that

...

  1. DAS

...

  1. can

...

  1. execute

...

  1. against

...

  1. Database)

...

  1. and

...

  1. Database

...

  1. schema

...

  1. like

...

  1. -

...

  1. Table/Columns,

...

  1. Relationship

...

  1. and

...

  1. so

...

  1. forth.

...

  1. Please

...

  1. check

...

  1. Architecture

...

  1. Guide

...

  1. for

...

  1. complete

...

  1. details

...

  1. about

...

  1. Config.xsd

...

  1. ()

...


  1. at

...

  1. http://cwiki.apache.org/confluence/display/TUSCANY/RDB+DAS+-+Architecture+GuideImage Added.

...

  1. Modify

...

  1. Config

...

  1. get

...

  1. converter

...

  1. working.

...

  1. The

...

  1. <ConnectionInfo>

...

  1. element

...

  1. should

...

  1. match

...

  1. the

...

  1. resource

...

  1. name

...

  1. from

...

  1. server.xml

...

  1. for

...

  1. DataSource.Add

...

  1. a

...

  1. <Table>

...

  1. which

...

  1. has

...

  1. a

...

  1. column

...

  1. with

...

  1. converter

...

  1. class

...

  1. name

...

  1. of

...

  1. the

...

  1. class

...

  1. you

...

  1. just

...

  1. created.

...

  1. Add

...

  1. a

...

  1. <Command>

...

  1. with

...

  1. kind="Select"

...

  1. for

...

  1. this

...

  1. table/column

...

  1. e.g.

...

  1. No Format

...

  1. 
    <Command name="getFirstCustomer" SQL="Select * from CUSTOMER where ID = 1" kind="Select"/>
    
    <Table tableName="CUSTOMER">
    <Column columnName="ID" primaryKey="true"/>
    <Column columnName="LASTNAME" converterClassName="org.apache.tuscany.das.rdb.test.mappings.StringObfuscationConverter"/>
    </Table>
    

...

  1. #Now

...

  1. the

...

  1. code

...

  1. and

...

  1. config

...

  1. setup

...

  1. is

...

  1. complete.

...

  1. What

...

  1. remains

...

  1. is

...

  1. calling

...

  1. the

...

  1. new

...

  1. command

...

  1. from

...

  1. .jsp

...

  1. and

...


  1. servlet.

...

  1. Follow

...

  1. the

...

  1. technique

...

  1. similar

...

  1. to

...

  1. CompanyClient.java

...

  1. and

...

  1. Company.jsp

...

  1. to

...

  1. call

...

  1. the

...

  1. new

...

  1. command.

...

  1. The

...

  1. returned

...

  1. results

...

  1. will

...

  1. verify

...

  1. that

...

  1. the

...

  1. converter

...

  1. is

...

  1. called

...

  1. and

...

  1. the

...

  1. column

...

  1. value

...

  1. from

...

  1. database

...

  1. is

...

  1. converted

...

  1. based

...

  1. on

...

  1. converter

...

  1. logic.

...


  1. #For

...

  1. more

...

  1. details

...

  1. check

...

  1. the

...

  1. test

...

  1. cases

...

  1. from

...

  1. ConverterTests

...

  1. in

...

  1. https://svn.apache.org/repos/asf/incubator/tuscany/java/das/rdb/src/test/Image Added.

...

Similarly,

...

you

...

can

...

experiment

...

with

...

different

...

features

...

supported

...

by

...

DAS.

...

Assumption:

...

Tomcat

...

version

...

5.5.*

...

or

...

6.0.10

...

,

...

Derby

...

version

...

10.1.2.1.

...

Troubleshooting

...

Checkpoints:

...

Check

...

the

...

following

...

and

...

if

...

still

...

having

...

issues

...

,

...

report

...

at

...

http://cwiki.apache.org/confluence/display/TUSCANY/Issue+Tracking

...

Image Added

  1. All

...

  1. libraries

...

  1. are

...

  1. present

...

  1. in

...

  1. (Tomcat

...

  1. root)/webapps/companyweb/WEB-INF/lib

...

  1. (these

...

  1. libs

...

  1. can

...


  1. be

...

  1. taken

...

  1. from

...

  1. companyweb

...

  1. sample

...

  1. or

...

  1. can

...

  1. be

...

  1. downloaded

...

  1. from

...

  1. web)

...


  1. i)

...

  1. common-

...

  1. (latest

...

  1. version

...

  1. ).jar

...


  1. ii)

...

  1. ecore-

...

  1. (latest

...

  1. version

...

  1. ).jar

...


  1. iii)

...

  1. ecore-change-

...

  1. (latest

...

  1. version

...

  1. ).jar

...


  1. iv)

...

  1. ecore-xmi-

...

  1. (latest

...

  1. version

...

  1. ).jar

...


  1. v)

...

  1. log4j-

...

  1. (latest

...

  1. version

...

  1. ).jar

...


  1. vi)

...

  1. sdo-api-xxx.jar

...


  1. vii)

...

  1. tuscany-das-rdb-xxx.jar

...


  1. viii)

...

  1. tuscany-sdo-xxx.jar

...


  1. ix)

...

  1. xsd-

...

  1. (latest

...

  1. version

...

  1. ).jar

...


  1. x)

...

  1. derby

...

  1. driver

...

  1. jar

...

  1. -

...

  1. or

...

  1. whichever

...

  1. database

...

  1. you

...

  1. are

...

  1. planning

...

  1. to

...

  1. use

...

  1. The

...

  1. Database

...

  1. exists

...

  1. with

...

  1. required

...

  1. tables

...

  1. and

...

  1. data.

...

  1. WEB-INF/web.xml

...

  1. has

...

  1. entry

...

  1. under

...

  1. welcome-file-list

...

  1. for

...

  1. required

...

  1. .jsp

...

  1. like

...

  1. -

...

  1. No Format
    
    <web-app>
        <display-name>Tuscany DAS sample Company  WEB</display-name>
    
        <welcome-file-list id="WelcomeFileList">
            <welcome-file>Company.jsp</welcome-file>
        </welcome-file-list>
    </web-app>
    

...

  1. META-INF/context.xml

...

  1. has

...

  1. entry

...

  1. for

...

  1. the

...

  1. datasource

...

  1. the

...

  1. sample

...

  1. is

...

  1. using

...

  1. like

...

  1. -

...

  1. No Format

...

  1. 
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/DAS Stand alone app" debug="5" reloadable="true" crossContext="true">
       <Manager pathname=""/>
       <ResourceLink name="jdbc/dastest" global="jdbc/dastest" type="javax.sql.DataSource" />                     
    </Context>
    

...

  1. (Tomcat

...

  1. root)/conf

...

  1. server.xml

...

  1. has

...

  1. entry

...

  1. similar

...

  1. to

...

  1. below

...

  1. for

...

  1. the

...

  1. datasource

...

  1. -

...

  1. No Format

...

  1. 
    <Resource name="jdbc/dastest"
          type="javax.sql.DataSource"  auth="Container"
          description="Derby database for DAS Company sample"
          maxActive="100" maxIdle="30" maxWait="10000"
          username="" password=""
          driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
          url="jdbc:derby:c:\apache-tomcat-5.5.20\Databases/dastest;create=true"/>
    

...

_______________________________________________________________________________________________

  • old guide - just to compare, can be deleted later -
    h1. Starting with DAS

This is a quick guide for building a simple aplication using DAS/SDO. You will learn the simple steps required to
build "CompanyWeb" sample web application. This sample users MySQL and Tomcat.

A. Initial Setup

  1. Install Tomcat(latest version) and MySQL(latest version). Please indicate which version of the Tomcat and MySQL is this tested with?
  2. Download dependencies and libraries Please add a link to this information. Which dependencies and libraries?
  3. Create companyweb directory in (Tomcat root)/webapps/. EX: (Tomcat root)/webapps/companyweb
  4. Create the directory (Tomcat root)/webapps/companyweb/WEB-INF/lib

...

  1. and

...

  1. copy

...

  1. the

...

  1. libraries

...

  1. into

...

  1. it.

...

  1. As

...

  1. an

...

  1. alternative,

...

  1. you

...

  1. can

...

  1. copy

...

  1. the

...

  1. libraries

...

  1. into

...

  1. (Tomcat

...

  1. root)/common/lib

...

  1. directory.

...

  1. The

...

  1. required

...

  1. libraries

...

  1. are:

...


  1. i)

...

  1. common-(latest

...

  1. version).jar

...


  1. ii)

...

  1. ecore-(latest

...

  1. version).jar

...


  1. iii)

...

  1. ecore-change-(latest

...

  1. version).jar

...


  1. iv)

...

  1. ecore-xmi-(lateste

...

  1. version).jar

...


  1. v)

...

  1. log4j-(latest

...

  1. version).jar

...


  1. vi)

...

  1. sdo-api-xxx.jar

...


  1. vii)

...

  1. tuscany-das-rdb-xxx.jar

...


  1. viii)

...

  1. tuscany-sdo-xxx.jar

...


  1. ix)

...

  1. xsd-(latest

...

  1. version).jar

...


  1. x)

...

  1. mysql-connector-java-(latest

...

  1. version).jar

...

  1. ->

...

  1. This

...

  1. is

...

  1. the

...

  1. JDBC

...

  1. connector,

...

  1. It'll

...

  1. be

...

  1. used

...

  1. to

...

  1. connect

...

  1. to

...

  1. Mysql

...

  1. database

B.

...

Creating

...

CompanyWeb

...

Database

...

After

...

setting

...

up

...

your

...

enviroment,

...

the

...

next

...

step

...

will

...

be

...

to

...

create

...

the

...

databse

...

where

...

the

...

DAS

...

will

...

interact

...

with.

...

  1. Run

...

  1. the

...

  1. following

...

  1. commands

...

  1. in

...

  1. the

...

  1. MySQL

...

  1. Command

...

  1. Shell
    create database companyweb;

...

  1. ->

...

  1. This

...

  1. command

...

  1. will

...

  1. create

...

  1. the

...

  1. CompanyWeb

...

  1. database

...


  1. use

...

  1. companyweb;

...

  1. ->

...

  1. Set

...

  1. the

...

  1. shell

...

  1. to

...

  1. work

...

  1. with

...

  1. companyweb

...

  1. database

...

  1. Create

...

  1. a

...

  1. text

...

  1. file

...

  1. and

...

  1. name

...

  1. it

...

  1. as

...

  1. "comapnyweb.sql",

...

  1. you

...

  1. should

...

  1. insert

...

  1. the

...

  1. following

...

  1. lines

...

  1. in

...

  1. this

...

  1. file

...

  1. No Format

...

  1. 
    CREATE TABLE EMPLOYEE ( 
    ID INTEGER NOT NULL AUTO_INCREMENT, NAME VARCHAR(30), SN VARCHAR(10), MANAGER SMALLINT, DEPARTMENTID INTEGER, PRIMARY KEY (ID) 
    ); 
    
    CREATE TABLE DEPARTMENT ( 
    ID INTEGER NOT NULL AUTO_INCREMENT, NAME VARCHAR(30), LOCATION VARCHAR(30), NUMBER VARCHAR(10), COMPANYID INTEGER, EOTM INTEGER, PRIMARY KEY (ID) 
    ); 
    
    CREATE TABLE COMPANY ( 
    ID INTEGER NOT NULL AUTO_INCREMENT, NAME VARCHAR(30), PRIMARY KEY (ID) 
    ); 
    
    CREATE UNIQUE INDEX SQL060217085530980 ON COMPANY (ID ASC); 
    
    CREATE UNIQUE INDEX SQL060217085531710 ON DEPARTMENT (ID ASC); 
    
    INSERT INTO COMPANY VALUES (51, "ACME Publishing"); 
    
    INSERT INTO COMPANY VALUES (52, "Do-rite plumbing"); 
    
    INSERT INTO COMPANY VALUES (53, "MegaCorp"); 
    

...

  1. Run the following command in the Mysql Shell to execute the script that creates tables, constraints, etc.
    Code Block
    
    source (path)/companyweb

...

  1. .sql  
    

C. Creating XML configuration file

Would be nice to explain what this file is used for

  1. Create the file CompanyConfig.xml in the directory (Tomcat root)/webapps/companyweb/WEB-INF/classes

...

  1. Edit

...

  1. it

...

  1. and

...

  1. write

...

  1. the

...

  1. following

...

  1. code

...

  1. No Format

...

  1. 
    <?xml version="1.0" encoding="ASCII"?> 
    <Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd"> 
    
    <Command name="all companies" SQL="select * from COMPANY" kind="Select"/> 
    <Command name="all companies and departments" SQL="select * from COMPANY left outer join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID" kind="Select"/> 
    <Command name="all departments for company" SQL="select * from COMPANY inner join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID where COMPANY.ID = ?" kind="Select"/> 
    <Command name="company by id with departments" SQL="select * from COMPANY left outer join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID where COMPANY.ID = ?" kind="Select"/> 
    <Table tableName="COMPANY"> 
    <Column columnName="ID" primaryKey="true" generated="true"/> 
    </Table> 
    <Table tableName="DEPARTMENT"> 
    ?	<Column columnName="ID" primaryKey="true" generated="true"/> 
    </Table> 
    <Relationship name="departments" primaryKeyTable="COMPANY" foreignKeyTable="DEPARTMENT" many="true"> 
    <KeyPair primaryKeyColumn="ID" foreignKeyColumn="COMPANYID"/> 
    </Relationship> 
    </Config> 
    

...

  1. Save the file.

D. Creating the class and jsp which manages the DAS/SDO features

What do you mean by a class manages DAS/SDO features? Do you mean, a class that manipulates or uses DAS/SDO features?

  1. Create the file CompanyClient.java in the directory (Tomcat root)/webapps/companyweb/WEB-INF/classes/org/apache/tuscany/samples/das/companyweb

...

  1. Write

...

  1. the

...

  1. following

...

  1. code

...

  1. in

...

  1. the

...

  1. file :
    It would be helpful to explain what the purpose of this code is. I would suggest you move this code to another page since it is so long and instead have a link on this page
No Format
 : 
[comment: It would be helpful to explain what the purpose of this code is. I would suggest you move this code to another page since it is so long and instead have a link on this page]

{noformat}
package org.apache.tuscany.samples.das.companyweb;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

import org.apache.tuscany.das.rdb.Command;
import org.apache.tuscany.das.rdb.DAS;

import commonj.sdo.DataObject;

public class CompanyClient {

    private Random generator = new Random();

    private DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"));

    public final List getCompanies() {

        Command read = das.getCommand("all companies");
        DataObject root = read.executeQuery();
        return root.getList("COMPANY");

    }

    public final List getCompaniesWithDepartments() {

        Command read = das.getCommand("all companies and departments");
        DataObject root = read.executeQuery();
        return root.getList("COMPANY");
    }

    public final List getDepartmentsForCompany(int id) {
        Command read = das.getCommand("all departments for company");
        read.setParameter(1, new Integer(id));
        DataObject root = read.executeQuery();
        return root.getList("COMPANY");
    }

    public final void addDepartmentToFirstCompany() {
        Command read = das.getCommand("all companies and departments");
        DataObject root = read.executeQuery();
        DataObject firstCustomer = root.getDataObject("COMPANY[1]");

        DataObject newDepartment = root.createDataObject("DEPARTMENT");
        newDepartment.setString("NAME", "Default Name");
        firstCustomer.getList("departments").add(newDepartment);

        das.applyChanges(root);

    }

    public final void deleteDepartmentsFromFirstCompany() {

        // This section gets the ID of the first Company just so I can
        // demonstrate a parameterized command next
        Command readAll = das.getCommand("all companies and departments");
        DataObject root = readAll.executeQuery();
        int idOfFirstCustomer = root.getInt("COMPANY[1]/ID");
        System.out.println("ID of first company is: " + idOfFirstCustomer);

        // Read a specific company based on the known ID
        Command readCust = das.getCommand("company by id with departments");
        readCust.setParameter(1, new Integer(idOfFirstCustomer));
        root = readCust.executeQuery();

        // Delete all the comany's departments from the graph
        DataObject firstCustomer = root.getDataObject("COMPANY[1]");

        // Shallow copy of list for deleting. This is required to avoid the
        // dreaded
        // ConcurrentModificationException since #delete operation also removes
        // from the original list
        List allDepartments = new ArrayList(firstCustomer.getList("departments"));

        Iterator i = allDepartments.iterator();
        DataObject department;
        while (i.hasNext()) {
            department = (DataObject) i.next();
            System.out.println("Deleting department named: " + department.getString("NAME"));
            department.delete();
        }

        das.applyChanges(root);

    }

    public final void changeFirstCompanysDepartmentNames() {

        // This section gets the ID of the first Company just so I can
        // demonstrate a parameterized command next
        Command readAll = das.getCommand("all companies and departments");
        DataObject root = readAll.executeQuery();
        int idOfFirstCustomer = root.getInt("COMPANY[1]/ID");
        System.out.println("ID of first company is: " + idOfFirstCustomer);

        // Read a specific company based on the known ID
        Command readCust = das.getCommand("company by id with departments");
        readCust.setParameter(1, new Integer(idOfFirstCustomer));
        root = readCust.executeQuery();

        // Modify all the comany's department names
        DataObject firstCustomer = root.getDataObject("COMPANY[1]");
        Iterator i = firstCustomer.getList("departments").iterator();
        DataObject department;
        while (i.hasNext()) {
            department = (DataObject) i.next();
            System.out.println("Modifying department: " + department.getString("NAME"));
            department.setString("NAME", getRandomDepartmentName());
        }
        das.applyChanges(root);

    }
    
    
    public void releaseResources() {
        das.releaseResources();
    }

    // Utilities

    private String getRandomDepartmentName() {
        int number = generator.nextInt(1000) + 1;
        return "Dept-" + number;
    }

    private InputStream getConfig(String fileName) {
        return getClass().getClassLoader().getResourceAsStream(fileName);
    }

}
{noformat}
# Create following 
  1. Create following Company.jsp

...

  1. file

...

  1. under

...

  1. (Tomcat

...

  1. root)/webapps/companyweb.

...

  1. No Format

...

  1. 
    <html>
    <head>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    
    	pageEncoding="ISO-8859-1"
    
            import="org.apache.tuscany.samples.das.companyweb.CompanyClient"
            import="commonj.sdo.*"
    %>
    
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Company Test</title>
    </head>
    <body>
    
    <H2>Tuscany DAS Companies WEB Example</H2>
    
    
    <form>
    <input type="submit" id="doFill" name="doFill" value="All Companies">
    <input type="submit" id="doFillAll" name="doFillAll" value="All Companies/Departments">
    <input type="submit" id="doAddDepartment" name="doAddDepartment" value="Add department to first company">
    <input type="submit" id="doChangeDepartmentNames" name="doChangeDepartmentNames" value="Change Company(1) Dept names">
    <input type="submit" id="doDeleteDepartments" name="doDeleteDepartments" value="Delete Company(1) Depts">
    <hr>
    
    <!-- Do Fill -->
    <%if(request.getParameter("doFill") != null){%>
    
    <table border>
    	<thead>
    		<tr>
    			<th>ID</th>
    			<th>Name</th>
    		</tr>
    	</thead>
    	<tbody>
    
    		<%
    		CompanyClient companyClient = new CompanyClient();
    		java.util.Iterator i = companyClient.getCompaniesWithDepartments().iterator();
    		while (i.hasNext()) {
    			DataObject company = (DataObject)i.next();
    		%>
    			<tr>
    				<td><%=company.getInt("ID")%></td>
    				<td><%=company.getString("NAME")%></td>
    			<tr>
    		<%	
    		}
    		companyClient.releaseResources();
    		%>
    		
    	</tbody>
    </table>
    <%}%>
    
    
    <!-- Do Add Department -->
    <%
    if(request.getParameter("doAddDepartment") != null){
        CompanyClient companyClient = new CompanyClient();
        companyClient.addDepartmentToFirstCompany();
        companyClient.releaseResources();
    }
    %>
    
    <!-- Do Delete Departments from first company -->
    <%
    if(request.getParameter("doDeleteDepartments") != null){
        CompanyClient companyClient = new CompanyClient();
        companyClient.deleteDepartmentsFromFirstCompany();
        companyClient.releaseResources();
    }
    %>
    
    <!-- Do Change First Company's Department Names -->
    <%
    if(request.getParameter("doChangeDepartmentNames") != null){
        CompanyClient companyClient = new CompanyClient();
        companyClient.changeFirstCompanysDepartmentNames();
        companyClient.releaseResources();
    }
    %>
    
    
    <!-- Do FillAll -->
    <%if(request.getParameter("doFill") == null) {%>
    
    <table border>
    	<thead>
    		<tr>
    			<th>ID</th>
    			<th>Name</th>
    			<th>Department_ID</th>
    			<th>Department_Name</th>
    		</tr>
    	</thead>
    	<tbody>
    
    		<%
    		CompanyClient companyClient = new CompanyClient();
    		java.util.Iterator i = companyClient.getCompaniesWithDepartments().iterator();
    		while (i.hasNext()) {
    			DataObject company = (DataObject)i.next();
    		%>
    			<tr>
    				<td><%=company.getInt("ID")%></td>
    				<td><%=company.getString("NAME")%></td>
    			<tr>
    
    			
    
    			<%
    			java.util.Iterator j = company.getList("departments").iterator();
    			while (j.hasNext()) {
    				DataObject department = (DataObject)j.next();
    			%>
    				<tr>
    					<td></td><td></td><td><%=department.getInt("ID")%></td>
    					<td><%=department.getString("NAME")%></td>
    				<tr>
    			<%	
    			}
    			%>
    		<%	
    		}
    		companyClient.releaseResources();
    		%>
    		
    	</tbody>
    </table>
    <%}%>
    
    </form>
    </body>
    </html>
    

...

E.

...

Creating

...

web

...

and

...

context

...

configuration

...

files

...

supporting

...

Tomcat

...

  1. Under

...

  1. WEB-INF

...

  1. create

...

  1. following

...

  1. web.xml

...

  1. file

...

  1. and

...

  1. save

...

  1. it.

...


  1. web.xml

...

  1. No Format

...

  1. 
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
    Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    
    <web-app>
        <display-name>Tuscany DAS sample Company  WEB</display-name>
    
        <welcome-file-list id="WelcomeFileList">
            <welcome-file>Company.jsp</welcome-file>
        </welcome-file-list>
    </web-app>
    

...

  1. Under META-INF

...

  1. create

...

  1. following

...

  1. context.xml

...

  1. file

...

  1. and

...

  1. save

...

  1. it.

...


  1. context.xml

...

  1. No Format

...

  1. 
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/DAS Stand alone app" debug="5" reloadable="true" crossContext="true">
       <Manager pathname=""/>
       <ResourceLink name="jdbc/dastest" global="jdbc/dastest" type="javax.sql.DataSource" />                     
    </Context>
    

...

  1. Under (Tomcat

...

  1. root)/conf

...

  1. modify

...

  1. server.xml

...

  1. with

...

  1. following

...

  1. entry

...

  1. in

...

  1. <GlobalNamingResources>

...

  1. No Format

...

  1. 
    <Resource name="jdbc/dastest"
    type="javax.sql.DataSource"  auth="Container"
    description="MySQL database for DAS Web sample"
    maxActive="100" maxIdle="30" maxWait="10000"
    username="" password=""
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql:///dastest?user=xxx&password=yyy"/>
    

...

F.

...

Run

...

the

...

sample

...

companyweb

...

All

...

setup

...

is

...

complete

...

now.

...

Run

...

the

...

application

...

in

...

Tomcat

...

and

...

try

...

different

...

options

...

like

...

query

...

company

...

and

...


departments,

...

addition,

...

deletion.

...


How

...

do

...

I

...

run

...

this?

...

Can

...

you

...

provide

...

an

...

example?

...