This Tutorial purpose is to provide a simple "how to" and give a step-by-step to build a simple aplication using DAS/SDO features from Tuscany project. Here you'll build our "CompanyWeb Sample Web Application". This sample uses Mysql and Tomcat.

A. Initial Setup:

B. Creating CompanyWeb Database

CREATE TABLE EMPLOYEE (

CREATE TABLE DEPARTMENT (

CREATE TABLE COMPANY (

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");

C. Creating XML configuration file

  • 1- Create the file CompanyConfig.xml in the directory {Tomcat root}/webapps/companyweb/WEB-INF/classes 2- Edit it and write the following code:

<?xml version="1.0" encoding="ASCII"?> <Config xsi:noNamespaceSchemaLocation="http:///org.apache.tuscany.das.rdb/config.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  • <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>

  • 3- Save the file.

D. Creating the class wich manages the 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 2- Write the following code in the file :

--HOW to make the jsp. http://people.apache.org/~kelvingoodson/das_java/RC4b/

Tuscany/TuscanyJava/DAS_Java_Overview/RDBDAS_HOWTO_HelloDASApp (last edited 2009-09-20 22:47:30 by localhost)