You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by am...@apache.org on 2007/11/05 06:53:46 UTC

svn commit: r591886 - in /incubator/tuscany/java/das: distribution/binary/ distribution/binary/src/main/assembly/ rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ rdb/src/test/java/org/apache/tuscany/das/rdb/test/ rdb/src/test/java/org/apache/tuscany...

Author: amita
Date: Sun Nov  4 21:53:43 2007
New Revision: 591886

URL: http://svn.apache.org/viewvc?rev=591886&view=rev
Log: (empty)

Added:
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ConnectionTests.java
    incubator/tuscany/java/das/rdb/src/test/resources/connectionInfoDriverManagerAuth.xml
    incubator/tuscany/java/das/rdb/src/test/resources/connectionInfoDriverManagerNoAuth.xml
    incubator/tuscany/java/das/samples/dataSource/
    incubator/tuscany/java/das/samples/dataSource/build.xml
    incubator/tuscany/java/das/samples/dataSource/pom.xml
    incubator/tuscany/java/das/samples/dataSource/readme.htm
    incubator/tuscany/java/das/samples/dataSource/src/
    incubator/tuscany/java/das/samples/dataSource/src/main/
    incubator/tuscany/java/das/samples/dataSource/src/main/java/
    incubator/tuscany/java/das/samples/dataSource/src/main/java/org/
    incubator/tuscany/java/das/samples/dataSource/src/main/java/org/apache/
    incubator/tuscany/java/das/samples/dataSource/src/main/java/org/apache/tuscany/
    incubator/tuscany/java/das/samples/dataSource/src/main/java/org/apache/tuscany/samples/
    incubator/tuscany/java/das/samples/dataSource/src/main/java/org/apache/tuscany/samples/das/
    incubator/tuscany/java/das/samples/dataSource/src/main/java/org/apache/tuscany/samples/das/dataSource/
    incubator/tuscany/java/das/samples/dataSource/src/main/java/org/apache/tuscany/samples/das/dataSource/ViewBooks.java
    incubator/tuscany/java/das/samples/dataSource/src/main/resources/
    incubator/tuscany/java/das/samples/dataSource/src/main/resources/connectionInfoDataSourceAuth.xml
Modified:
    incubator/tuscany/java/das/distribution/binary/pom.xml
    incubator/tuscany/java/das/distribution/binary/src/main/assembly/das.xml
    incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GraphMergeTests.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/suites/AllCommonTests.java
    incubator/tuscany/java/das/samples/Readme.htm
    incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBConnectionHelper.java
    incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBHelper.java
    incubator/tuscany/java/das/samples/pom.xml

Modified: incubator/tuscany/java/das/distribution/binary/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/distribution/binary/pom.xml?rev=591886&r1=591885&r2=591886&view=diff
==============================================================================
--- incubator/tuscany/java/das/distribution/binary/pom.xml (original)
+++ incubator/tuscany/java/das/distribution/binary/pom.xml Sun Nov  4 21:53:43 2007
@@ -64,6 +64,12 @@
           <version>${das.version}</version>
       </dependency>
       
+       <dependency>
+          <groupId>org.apache.tuscany.das.samples</groupId>
+          <artifactId>tuscany-das-sample-dataSource</artifactId>
+          <version>${das.version}</version>
+      </dependency>
+      
     </dependencies>
 
     <build>

Modified: incubator/tuscany/java/das/distribution/binary/src/main/assembly/das.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/distribution/binary/src/main/assembly/das.xml?rev=591886&r1=591885&r2=591886&view=diff
==============================================================================
--- incubator/tuscany/java/das/distribution/binary/src/main/assembly/das.xml (original)
+++ incubator/tuscany/java/das/distribution/binary/src/main/assembly/das.xml Sun Nov  4 21:53:43 2007
@@ -112,6 +112,24 @@
                <outputDirectory>tuscany-das-${das.version}/samples/transaction</outputDirectory>
                <fileMode>0644</fileMode>
             </file>
+            
+            <!-- include readme for dataSource sample -->
+            <file>
+               <source>../../samples/dataSource/readme.htm</source>
+               <outputDirectory>tuscany-das-${das.version}/samples/dataSource</outputDirectory>
+               <fileMode>0644</fileMode>
+            </file>
+            <!-- include dataSource sample -->
+            <file>
+               <source>../../samples/dataSource/target/sample-dataSource.jar</source>
+               <outputDirectory>tuscany-das-${das.version}/samples/dataSource</outputDirectory>
+               <fileMode>0644</fileMode>
+            </file>
+            <file>
+               <source>../../samples/dataSource/build.xml</source>
+               <outputDirectory>tuscany-das-${das.version}/samples/dataSource</outputDirectory>
+               <fileMode>0644</fileMode>
+            </file>            
         </files>
 
 
@@ -146,5 +164,14 @@
 	        </includes>	    
 	    <fileMode>0644</fileMode>
         </dependencySet>
+        
+	<!-- DAS Samples - dataSource mysql dependency-->
+        <dependencySet>
+	    <outputDirectory>tuscany-das-${das.version}/samples/dataSource</outputDirectory>
+	        <includes>
+	            <include>mysql:mysql-connector-java</include>
+	        </includes>	    
+	    <fileMode>0644</fileMode>
+        </dependencySet>        
     </dependencySets>
 </assembly>

Modified: incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java?rev=591886&r1=591885&r2=591886&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java (original)
+++ incubator/tuscany/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/DASImpl.java Sun Nov  4 21:53:43 2007
@@ -143,19 +143,22 @@
     private void initializeConnection() {
         Config config = configWrapper.getConfig();
         if (config == null || config.getConnectionInfo() == null ||
-            (config.getConnectionInfo().getDataSource() == null && config.getConnectionInfo().getConnectionProperties() == null)) {
+            (config.getConnectionInfo().getDataSource() == null &&
+            		(config.getConnectionInfo().getConnectionProperties() == null || config.getConnectionInfo().getConnectionProperties().getDatabaseURL() == null
+            		|| config.getConnectionInfo().getConnectionProperties().getDriverClass() == null)) ) {
             throw new RuntimeException("No connection has been provided and no data source has been specified");
         }
 
-        if(config.getConnectionInfo().getDataSource() != null && config.getConnectionInfo().getConnectionProperties() != null){
-            throw new RuntimeException("Use either dataSource or ConnectionProperties. Can't use both !");
+        if(config.getConnectionInfo().getDataSource() != null &&
+        		(config.getConnectionInfo().getConnectionProperties() != null && config.getConnectionInfo().getConnectionProperties().getDatabaseURL() != null) ){
+            throw new RuntimeException("Use either dataSource or databaseURL. Can't use both !");
         }
 
         ConnectionInfo connectionInfo = configWrapper.getConfig().getConnectionInfo();
-        if(config.getConnectionInfo().getConnectionProperties() != null){
-            initializeDriverManagerConnection(connectionInfo);
+        if(config.getConnectionInfo().getDataSource() != null){
+        	initializeDatasourceConnection(connectionInfo);
         }else{
-            initializeDatasourceConnection(connectionInfo);
+        	initializeDriverManagerConnection(connectionInfo);
         }
 
     }
@@ -175,7 +178,18 @@
         try {
             DataSource ds = (DataSource) ctx.lookup(connectionInfo.getDataSource());
             try {
-                connection = ds.getConnection();
+            	try {
+	            	if(connectionInfo.getConnectionProperties() != null &&
+	            	   connectionInfo.getConnectionProperties().getUserName() != null &&
+	            	   connectionInfo.getConnectionProperties().getPassword() != null ) {
+	            		connection = ds.getConnection(connectionInfo.getConnectionProperties().getUserName(), connectionInfo.getConnectionProperties().getPassword());
+	            	} else {
+	            		connection = ds.getConnection();
+	            	}
+            	}catch(Exception e) {
+            		connection = ds.getConnection();
+            	}
+
                 if (connection == null) {
                     throw new RuntimeException("Could not obtain a Connection from DataSource");
                 }

Added: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ConnectionTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ConnectionTests.java?rev=591886&view=auto
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ConnectionTests.java (added)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ConnectionTests.java Sun Nov  4 21:53:43 2007
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.das.rdb.test;
+
+import java.sql.Statement;
+import java.sql.Connection;
+import java.util.Properties;
+
+import org.apache.derby.jdbc.EmbeddedDataSource;
+import org.apache.tuscany.das.rdb.DAS;
+import org.apache.tuscany.das.rdb.test.framework.DasTest;
+
+import commonj.sdo.DataObject;
+
+public class ConnectionTests extends DasTest {
+	Properties p = null;
+	
+    protected void setUp() throws Exception {        
+        super.setUp();
+        p = System.getProperties();
+        p.put("derby.system.home", "target");
+
+        EmbeddedDataSource ds = new EmbeddedDataSource();       
+    	ds.setDatabaseName("dastestcon");
+    	ds.setDataSourceName("java/dastestcon");
+   		ds.setCreateDatabase("create");
+   		ds.setUser("dasuser");
+   		ds.setPassword("dasuser");
+   		Connection connection = ds.getConnection("dasuser", "dasuser");//to actually create the database
+   		Statement stmt = connection.createStatement();
+   		try{
+   			stmt.executeQuery("select * from BOOK");
+   		} catch(Exception e) {
+	   		stmt.execute("create table BOOK (id int, name varchar(30))");
+	   		stmt.execute("insert into BOOK values (1, 'book1')");
+   		}
+   		connection.commit();
+   		connection.close();   		
+    }
+    
+    protected void tearDown() throws Exception {
+    	super.tearDown();
+    }
+
+    /*As database is created with user, password, connection without same authentication can not look up data*/
+    public void testConnectionUsingDriverManagerNoAuth() throws Exception {
+    	try {
+	   		DAS das = DAS.FACTORY.createDAS(getConfig("connectionInfoDriverManagerNoAuth.xml"));
+	   		das.getCommand("getBook").executeQuery();
+	   		fail("Expected exception, as DB is created with id, pwd, needs same to get data from DB!");
+		} catch(Exception e) {
+			//e.printStackTrace();
+			assertTrue(true);//Expected exception
+		}
+    }
+    
+    /*As database is created with user, password, connection with same authentication can look up data*/
+    public void testConnectionUsingDriverManagerAuth() throws Exception {
+    	try {
+	   		DAS das = DAS.FACTORY.createDAS(getConfig("connectionInfoDriverManagerAuth.xml"));
+	   		DataObject root = das.getCommand("getBook").executeQuery();
+	   		assertEquals(1, root.getList("BOOK").size());
+		} catch(Exception e) {
+			fail("Expected DAS to obtain authenticated connection using data source!");
+		}
+    }    
+}

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GraphMergeTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GraphMergeTests.java?rev=591886&r1=591885&r2=591886&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GraphMergeTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GraphMergeTests.java Sun Nov  4 21:53:43 2007
@@ -6,15 +6,15 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 package org.apache.tuscany.das.rdb.test;
 
@@ -60,7 +60,7 @@
     public void testCreateEmptyGraph() throws Exception {
         String typeUri = "http:///org.apache.tuscany.das.rdb.test/customer.xsd";
         HelperContext context = HelperProvider.getDefaultContext();
-        CustomerFactory.INSTANCE.register(context);  
+        CustomerFactory.INSTANCE.register(context);
         ConfigHelper helper = new ConfigHelper();
         helper.setDataObjectModel(typeUri);
         DataObject graph = new GraphMerger().emptyGraph(helper.getConfig());
@@ -137,7 +137,7 @@
         }
         assertEquals(5, mergedGraph.getList("CUSTOMER").size());
     }
-    
+
     public void testSingleTableMergeThreeGraphs() throws Exception {
         DAS das = DAS.FACTORY.createDAS(getConnection());
         Command select = das.createCommand("Select ID, LASTNAME, ADDRESS from CUSTOMER where ID <= ?");
@@ -168,7 +168,7 @@
     public void testMultiTableMerge2() throws Exception {
         DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
         // Read some customers and related orders
-        Command select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON " 
+        Command select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON "
                 + "CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
 
         select.setParameter(1, new Integer(1));
@@ -203,7 +203,7 @@
     public void testMultiTableAppendSingleTable2() throws Exception {
         DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
         // Read some customers and related orders
-        Command select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON " 
+        Command select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON "
                 + "CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
 
         select.setParameter(1, new Integer(1));
@@ -226,7 +226,7 @@
     }
 
     /**
-     * Mix dynamic DO from query result with static DO from customer.xsd. As long as the type and 
+     * Mix dynamic DO from query result with static DO from customer.xsd. As long as the type and
      * property names are matching for both, merge can happen - fixing bug 1827- pk hashmap was not
      * considering type and property names before.
      * @throws Exception
@@ -236,10 +236,10 @@
         DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfigProps.xml"), getConnection());
     	DataObject root = das.getCommand("all customers").executeQuery();
     	DataObject firstCustomer = root.getDataObject("Customer[ID=1]");
-    	
+
     	if(firstCustomer != null)
     		firstCustomer.delete();//DAS will not automatic createOrReplace , so do delete here and later doing a create
-    	
+
     	//create new customer using static SDO - say a service is doing it
     	String typeUri = "http:///org.apache.tuscany.das.rdb.test/customer.xsd";
         HelperContext context = HelperProvider.getDefaultContext();
@@ -255,13 +255,18 @@
         c.setID(1);
         c.setLastName("WilliamsNew");
         c.setAddress("400 Fourth Street");
-        
+
         gm.addPrimaryKey("CUSTOMER.ID");
-        
-        DataObject root1 = gm.merge(root, ((DataObject)c).getRootObject());       
+
+        DataObject root1 = gm.merge(root, ((DataObject)c).getRootObject(), false);
         das.applyChanges(root1);
+
+        root = das.getCommand("all customers").executeQuery();
+        firstCustomer = root.getDataObject("Customer[ID=1]");
+        assertNotNull(firstCustomer);
+        assertEquals("WilliamsNew", firstCustomer.getString("lastName"));
     }
-    
+
     /**
      * Support merge(StaticDO1, StaticDO2, noChangeSummary) when both are not contained in "DataGraphRoot" and DataGraph (and not have changeSummary). When
      * no existing change summary, will be used for INSERT
@@ -276,26 +281,26 @@
         InputStream inputStream = url.openStream();
         XSDHelper.INSTANCE.define(inputStream, url.toString());
         inputStream.close();
-           
+
         Type singerType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SINGER");
         DataObject SINGER = DataFactory.INSTANCE.create(singerType);
         SINGER.set("ID", new Integer(100));
         SINGER.set("NAME", "Singer100"); */
-                
+
    	// Populate the meta data for the test (SINGER) using generated classes - WAY TWO
         SINGER singerStaticDO1 = SingerFactoryImpl.INSTANCE.createSINGER();
         singerStaticDO1.setID(100);
         singerStaticDO1.setNAME("Singer100");
-                        
+
         SINGER singerStaticDO2 = SingerFactoryImpl.INSTANCE.createSINGER();
         singerStaticDO2.setID(200);
         singerStaticDO2.setNAME("Singer200");
-        
+
         GraphMerger gm = new GraphMerger();
         gm.addPrimaryKey("SINGER.ID");
-        
+
         DataObject songs = gm.merge((DataObject)singerStaticDO1, (DataObject)singerStaticDO2, false);
- 
+
         DAS das = DAS.FACTORY.createDAS(getConnection());
         das.applyChanges(songs);
         //printSingerData();
@@ -305,7 +310,7 @@
     	assertEquals("Singer100", root.getDataObject("SINGER[ID=100]").getString("NAME"));
     	assertNotNull(root.getDataObject("SINGER[ID=200]"));
     	assertEquals("Singer200", root.getDataObject("SINGER[ID=200]").getString("NAME"));
-   }  
+   }
 
     /*Internal utility to create a property in a dynamic DO*/
     private void specifyProperty(DataObject containingTypeDO, String nameString, Type type, boolean isMany) {
@@ -314,13 +319,13 @@
         subordinateProperty.set("type", type);
         subordinateProperty.setBoolean("many", isMany);
     }
-    
+
     /*Internal utility to form Dynamic DO*/
     private DataObject formDynamicDO(String dynamicRootType) {
     	String DYNAMIC_TYPES_URI = "http://www.example.com/dynamicTypesFromSchemaSimple";
     	String DYNAMIC_ROOT_TYPE_0 = dynamicRootType;
     	String COMMONJ_SDO = "commonj.sdo";
-    	
+
     	HelperContext hcDO = SDOUtil.createHelperContext();
 
         TypeHelper thDO = hcDO.getTypeHelper();
@@ -341,9 +346,9 @@
         DataObject doFromApiAndDynTyp = dfDO.create(containerType);
         return doFromApiAndDynTyp;
     }
-    
+
     /**merge(DynamicDO1, DynamicDO2, noChangeSummary). When no change summary associated in a DataGraph, treated for INSERT
-     * 
+     *
      * @throws Exception
      */
     public void testMergeDynamicDOs() throws Exception {
@@ -351,17 +356,17 @@
         assertNotNull(doFromApiAndDynTyp1);
         doFromApiAndDynTyp1.setString("NAME", "DynamicSinger1");
         doFromApiAndDynTyp1.setInt("ID", 100);
-        
+
         DataObject doFromApiAndDynTyp2 = formDynamicDO("SINGER");
         assertNotNull(doFromApiAndDynTyp2);
         doFromApiAndDynTyp2.setString("NAME", "DynamicSinger2");
         doFromApiAndDynTyp2.setInt("ID", 200);
-        
+
         GraphMerger gm = new GraphMerger();
         gm.addPrimaryKey("SINGER.ID");
-        
+
         DataObject dos = gm.merge(doFromApiAndDynTyp1, doFromApiAndDynTyp2, false);
-        
+
         DAS das = DAS.FACTORY.createDAS(getConnection());
         das.applyChanges(dos);
         //printSingerData();
@@ -370,9 +375,9 @@
     	assertNotNull(root.getDataObject("SINGER[ID=100]"));
     	assertEquals("DynamicSinger1", root.getDataObject("SINGER[ID=100]").getString("NAME"));
     	assertNotNull(root.getDataObject("SINGER[ID=200]"));
-    	assertEquals("DynamicSinger2", root.getDataObject("SINGER[ID=200]").getString("NAME"));        
+    	assertEquals("DynamicSinger2", root.getDataObject("SINGER[ID=200]").getString("NAME"));
     }
-    
+
     /**
      * merge(StaticDO, DynamicDO, noChangeSummary). As no change summary, used for INSERT
      * @throws Exception
@@ -382,16 +387,16 @@
         assertNotNull(singerDynamicDO1);
         singerDynamicDO1.setString("NAME", "Singer100");
         singerDynamicDO1.setInt("ID", 100);
-        
+
     	SINGER singerStaticDO1 = SingerFactoryImpl.INSTANCE.createSINGER();
         singerStaticDO1.setID(200);
         singerStaticDO1.setNAME("Singer200");
-                        
+
         GraphMerger gm = new GraphMerger();
         gm.addPrimaryKey("SINGER.ID");
-        
+
         DataObject singers = gm.merge((DataObject)singerStaticDO1, singerDynamicDO1, false);
- 
+
         DAS das = DAS.FACTORY.createDAS(getConnection());
         das.applyChanges(singers);
         //printSingerData();
@@ -400,10 +405,10 @@
     	assertNotNull(root.getDataObject("SINGER[ID=100]"));
     	assertEquals("Singer100", root.getDataObject("SINGER[ID=100]").getString("NAME"));
     	assertNotNull(root.getDataObject("SINGER[ID=200]"));
-    	assertEquals("Singer200", root.getDataObject("SINGER[ID=200]").getString("NAME"));        
+    	assertEquals("Singer200", root.getDataObject("SINGER[ID=200]").getString("NAME"));
     }
 
-    /** 
+    /**
      * Query result can carry ChangeSummary of CUD, Dynamic DO will be a new Object (CREATE)
      * @throws Exception
      */
@@ -412,23 +417,23 @@
         assertNotNull(singerDynamicDO1);
         singerDynamicDO1.setString("NAME", "Singer100");
         singerDynamicDO1.setInt("ID", 100);
-        
+
         DAS das = DAS.FACTORY.createDAS(getConnection());
         Command cmd = das.createCommand("SELECT ID, NAME FROM SINGER");
         DataObject root = cmd.executeQuery();
-        
+
         DataObject secondSinger = root.getDataObject("SINGER[ID=2]");
         secondSinger.setString("NAME", "JaneSecond");//change summary registers Update change
-        
+
         DataObject thirdSinger = root.getDataObject("SINGER[ID=3]");
         thirdSinger.delete();//change summary registers Delete change
-        
+
         GraphMerger gm = new GraphMerger();
         gm.addPrimaryKey("SINGER.ID");
-        
+
         DataObject singers = gm.merge(root, singerDynamicDO1, false);//merge with primary DO having change summary and secondary DO without one.
         //as false is passed, secondary DO will be treated as INSERT in primaryChangeSummary
- 
+
         das.applyChanges(singers);
         //printSingerData();
     	root = cmd.executeQuery();
@@ -438,8 +443,8 @@
     	assertEquals("JaneSecond", root.getDataObject("SINGER[ID=2]").getString("NAME"));
     	assertNull(root.getDataObject("SINGER[ID=3]"));
     }
-    
-    /** 
+
+    /**
      * Query result can carry ChangeSummary of CUD, Static DO will be a new Object (CREATE)
      * @throws Exception
      */
@@ -447,7 +452,7 @@
     	SINGER singerStaticDO1 = SingerFactoryImpl.INSTANCE.createSINGER();
         singerStaticDO1.setID(100);
         singerStaticDO1.setNAME("Singer100");
-                        
+
         GraphMerger gm = new GraphMerger();
         gm.addPrimaryKey("SINGER.ID");
 
@@ -457,12 +462,12 @@
 
         DataObject secondSinger = root.getDataObject("SINGER[ID=2]");
         secondSinger.setString("NAME", "JaneSecond");//Change summary will register Update
-        
+
         DataObject thirdSinger = root.getDataObject("SINGER[ID=3]");
         thirdSinger.delete();//change summary will register Delete
 
         DataObject singers = gm.merge(root, (DataObject)singerStaticDO1, false);//due to false, secondary DO will be treated as INSERT in primary change summary
-        
+
         das.applyChanges(singers);
         //printSingerData();
     	root = cmd.executeQuery();
@@ -470,9 +475,9 @@
     	assertEquals("Singer100", root.getDataObject("SINGER[ID=100]").getString("NAME"));
     	assertNotNull(root.getDataObject("SINGER[ID=2]"));
     	assertEquals("JaneSecond", root.getDataObject("SINGER[ID=2]").getString("NAME"));
-    	assertNull(root.getDataObject("SINGER[ID=3]"));        
-    }    
-    
+    	assertNull(root.getDataObject("SINGER[ID=3]"));
+    }
+
     private void printSongData() throws Exception {
     	DAS das = DAS.FACTORY.createDAS(getConnection());
     	Command cmd = das.createCommand("SELECT ID, TITLE, SINGERID FROM SONG");
@@ -481,7 +486,7 @@
     	System.out.println(XMLHelper.INSTANCE.save(root, "song", "song"));
     	System.out.println("**********************************************");
     }
-    
+
     private void printSingerData() throws Exception {
     	DAS das = DAS.FACTORY.createDAS(getConnection());
     	Command cmd = das.createCommand("SELECT ID, NAME FROM SINGER");
@@ -490,7 +495,7 @@
     	System.out.println(XMLHelper.INSTANCE.save(root, "singer", "singer"));
     	System.out.println("**********************************************");
     }
-    
+
     /**
      * Mix all 3 - query result carrying change summary, static and dynamic DO
      * @throws Exception
@@ -499,32 +504,32 @@
     	SINGER singerStaticDO1 = SingerFactoryImpl.INSTANCE.createSINGER();
         singerStaticDO1.setID(200);
         singerStaticDO1.setNAME("Singer200");
-        
+
         GraphMerger gm = new GraphMerger();
         gm.addPrimaryKey("SINGER.ID");
-        
+
         DAS das = DAS.FACTORY.createDAS(getConnection());
         Command cmd = das.createCommand("SELECT ID, NAME FROM SINGER");
         DataObject root = cmd.executeQuery();
         DataObject firstSinger = root.getDataObject("SINGER[ID=1]");
         firstSinger.setString("NAME", "JohnNew");//change summary will register Update
-        
+
         DataObject secondSinger = root.getDataObject("SINGER[ID=2]");
         secondSinger.delete();//change summary will register Delete
-        
+
         DataObject singerDynamicDO1 = formDynamicDO("SINGER");
         assertNotNull(singerDynamicDO1);
         singerDynamicDO1.setString("NAME", "Singer100");
         singerDynamicDO1.setInt("ID", 100);
-        
-        ArrayList singersToMerge = new ArrayList();        
+
+        ArrayList singersToMerge = new ArrayList();
         singersToMerge.add((DataObject)singerStaticDO1);
         singersToMerge.add(root);
         singersToMerge.add(singerDynamicDO1);
-        
+
         //merge will internally shuffle DOs to detect primary having change summary. so root will be designated as Primary
         DataObject singers = gm.merge(singersToMerge, false);
-        
+
     	das.applyChanges(singers);
         //printSingerData();
     	root = cmd.executeQuery();
@@ -538,30 +543,30 @@
     }
 
     /**
-     * There is no much meaning to nested merges as the secondary DOs are at most treated for INSERTs. 
+     * There is no much meaning to nested merges as the secondary DOs are at most treated for INSERTs.
      * @throws Exception
      */
     public void testMergePrimaryQuerySecondaryStaticNested() throws Exception {
     	String typeUri = "http:///org.apache.tuscany.das.rdb.test/customer.xsd";
         HelperContext context = HelperProvider.getDefaultContext();
-        CustomerFactory.INSTANCE.register(context);  
-    	
+        CustomerFactory.INSTANCE.register(context);
+
     	AnOrder anOrderStaticDO1 = CustomerFactoryImpl.INSTANCE.createAnOrder();
     	anOrderStaticDO1.setID(100);
     	anOrderStaticDO1.setProduct("100 prods");
     	anOrderStaticDO1.setQuantity(100);
     	anOrderStaticDO1.setCustomer_ID(1);
-        
+
         GraphMerger gm = new GraphMerger();
         gm.addPrimaryKey("Customer.ID");
         gm.addPrimaryKey("AnOrder.ID");
-        
+
         ConfigHelper helper = new ConfigHelper();
         helper.setDataObjectModel(typeUri);
         helper.addTable("CUSTOMER", "Customer");
         helper.addTable("ANORDER", "AnOrder");
         MappingWrapper mappingWrapper = new MappingWrapper(helper.getConfig());
-        
+
         helper.addColumn(mappingWrapper.getTable("CUSTOMER"), "ID", "ID");
         helper.addColumn(mappingWrapper.getTable("CUSTOMER"), "LASTNAME", "lastName");
         helper.addColumn(mappingWrapper.getTable("CUSTOMER"), "ADDRESS", "address");
@@ -572,10 +577,10 @@
         helper.addColumn(mappingWrapper.getTable("ANORDER"), "CUSTOMER_ID", "Customer_ID");
 
         helper.addRelationship("CUSTOMER.ID", "ANORDER.CUSTOMER_ID", "orders");
-        
+
         DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
-        
-        Command cmd = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON " 
+
+        Command cmd = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON "
                 + "CUSTOMER.ID = ANORDER.CUSTOMER_ID");
         DataObject root = cmd.executeQuery();
 
@@ -583,16 +588,16 @@
         assertEquals(2, result.getDataObject("Customer[ID=1]").getList("orders").size()); //because only CREATE part
         //is considered for AnOrder, update part for relationship is not considered
         das.applyChanges(result);
-        
+
         context = HelperProvider.getDefaultContext();
         CustomerFactory.INSTANCE.register(context);
-        
+
         root = cmd.executeQuery();
         DataObject firstCustomer = root.getDataObject("Customer[ID=1]");
         List firstCustOrders = firstCustomer.getList("orders");
         assertEquals(3, root.getDataObject("Customer[ID=1]").getList("orders").size());//as now snapshot from DB
     }
-    
+
     /**
      * Show that when structure coming from Query is partial and the secondary is complete DO structure based on model xsd,
      * on-the-fly changes to structure are not allowed and merge does not happen
@@ -602,7 +607,7 @@
     	SINGER singerStaticDO1 = SingerFactoryImpl.INSTANCE.createSINGER();
     	singerStaticDO1.setID(100);
     	singerStaticDO1.setNAME("Singer100");
-                        
+
         GraphMerger gm = new GraphMerger();
         gm.addPrimaryKey("SINGER.ID");
 
@@ -613,8 +618,8 @@
         try {
 	        gm.merge(root, (DataObject)singerStaticDO1);
 	        fail("Expected exception!");
-        } catch(RuntimeException e) {        	
+        } catch(RuntimeException e) {
         	assertEquals("Graph structures do not match,", e.getMessage().substring(0, 30));
-        }        
-    }    
+        }
+    }
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/suites/AllCommonTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/suites/AllCommonTests.java?rev=591886&r1=591885&r2=591886&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/suites/AllCommonTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/suites/AllCommonTests.java Sun Nov  4 21:53:43 2007
@@ -6,15 +6,15 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 package org.apache.tuscany.das.rdb.test.suites;
 
@@ -28,6 +28,7 @@
 import org.apache.tuscany.das.rdb.test.CompanyTests;
 import org.apache.tuscany.das.rdb.test.CompoundKeyRelationshipTests;
 import org.apache.tuscany.das.rdb.test.CompoundKeyTests;
+import org.apache.tuscany.das.rdb.test.ConnectionTests;
 import org.apache.tuscany.das.rdb.test.ConverterTests;
 import org.apache.tuscany.das.rdb.test.CorrectedDefectTests;
 import org.apache.tuscany.das.rdb.test.CrudWithChangeHistory;
@@ -62,9 +63,9 @@
 
 public final class AllCommonTests {
 
-    private AllCommonTests() {  
+    private AllCommonTests() {
     }
-    
+
     public static Test suite() {
         TestSuite suite = new TestSuite("All platform-common DAS tests");
         // $JUnit-BEGIN$
@@ -109,15 +110,16 @@
         suite.addTest(new TestSuite(ImpliedRelationshipTests.class));
 
         suite.addTest(new TestSuite(KennelTests.class));
-        
+
         suite.addTest(new TestSuite(TransactionTests.class));
         suite.addTest(new TestSuite(MultiSchemaTests.class));
         suite.addTest(new TestSuite(MissingPKTests.class));
-    
+
 
         suite.addTest(new TestSuite(DynamicResultDescriptorTests.class));
         suite.addTest(new TestSuite(LOBTests.class));
         suite.addTest(new TestSuite(NamedParameterTests.class));
+        suite.addTest(new TestSuite(ConnectionTests.class));
         //$JUnit-END$
         return suite;
     }

Added: incubator/tuscany/java/das/rdb/src/test/resources/connectionInfoDriverManagerAuth.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/resources/connectionInfoDriverManagerAuth.xml?rev=591886&view=auto
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/resources/connectionInfoDriverManagerAuth.xml (added)
+++ incubator/tuscany/java/das/rdb/src/test/resources/connectionInfoDriverManagerAuth.xml Sun Nov  4 21:53:43 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd"> 
+ 
+<ConnectionInfo>
+    <ConnectionProperties
+        driverClass="org.apache.derby.jdbc.EmbeddedDriver"
+        databaseURL="jdbc:derby:dastestcon"
+        userName="dasuser"
+        password="dasuser"        
+        loginTimeout="600000"/>
+</ConnectionInfo>
+
+<Command name="getBook" SQL="Select * from BOOK" kind="Select"/>
+
+</Config>

Added: incubator/tuscany/java/das/rdb/src/test/resources/connectionInfoDriverManagerNoAuth.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/resources/connectionInfoDriverManagerNoAuth.xml?rev=591886&view=auto
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/resources/connectionInfoDriverManagerNoAuth.xml (added)
+++ incubator/tuscany/java/das/rdb/src/test/resources/connectionInfoDriverManagerNoAuth.xml Sun Nov  4 21:53:43 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd"> 
+ 
+<ConnectionInfo>
+    <ConnectionProperties
+        driverClass="org.apache.derby.jdbc.EmbeddedDriver"
+        databaseURL="jdbc:derby:dastestcon"
+        loginTimeout="600000"/>
+</ConnectionInfo>
+
+<Command name="getBook" SQL="Select * from BOOK" kind="Select"/>
+
+</Config>

Modified: incubator/tuscany/java/das/samples/Readme.htm
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/Readme.htm?rev=591886&r1=591885&r2=591886&view=diff
==============================================================================
--- incubator/tuscany/java/das/samples/Readme.htm (original)
+++ incubator/tuscany/java/das/samples/Readme.htm Sun Nov  4 21:53:43 2007
@@ -1,12 +1,89 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<HTML>
-<HEAD>
-	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
-	<TITLE>Tuscany RDB DAS Sample</TITLE>
-	<META NAME="GENERATOR" CONTENT="BrOffice.org 2.0  (Win32)">
-	<META NAME="CREATED" CONTENT="20070703;53381">
-	<META NAME="CHANGEDBY" CONTENT="a a">
-	<META NAME="CHANGED" CONTENT="20070703;190294">
+<html xmlns:o="urn:schemas-microsoft-com:office:office"
+xmlns:w="urn:schemas-microsoft-com:office:word"
+xmlns="http://www.w3.org/TR/REC-html40">
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
+<meta name=ProgId content=Word.Document>
+<meta name=Generator content="Microsoft Word 10">
+<meta name=Originator content="Microsoft Word 10">
+<link rel=File-List href="Readme_files/filelist.xml">
+<title>Tuscany RDB DAS Sample</title>
+<!--[if gte mso 9]><xml>
+ <o:DocumentProperties>
+  <o:Author>IBM_USER</o:Author>
+  <o:LastAuthor>IBM_USER</o:LastAuthor>
+  <o:Revision>7</o:Revision>
+  <o:TotalTime>7</o:TotalTime>
+  <o:Created>2007-11-01T11:52:00Z</o:Created>
+  <o:LastSaved>2007-11-05T04:30:00Z</o:LastSaved>
+  <o:Pages>1</o:Pages>
+  <o:Words>151</o:Words>
+  <o:Characters>864</o:Characters>
+  <o:Company>IBM</o:Company>
+  <o:Lines>7</o:Lines>
+  <o:Paragraphs>2</o:Paragraphs>
+  <o:CharactersWithSpaces>1013</o:CharactersWithSpaces>
+  <o:Version>10.6830</o:Version>
+ </o:DocumentProperties>
+</xml><![endif]--><!--[if gte mso 9]><xml>
+ <w:WordDocument>
+  <w:SpellingState>Clean</w:SpellingState>
+  <w:GrammarState>Clean</w:GrammarState>
+  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
+ </w:WordDocument>
+</xml><![endif]-->
+<style>
+<!--
+ /* Style Definitions */
+ p.MsoNormal, li.MsoNormal, div.MsoNormal
+	{mso-style-parent:"";
+	margin:0in;
+	margin-bottom:.0001pt;
+	mso-pagination:widow-orphan;
+	font-size:12.0pt;
+	font-family:"Times New Roman";
+	mso-fareast-font-family:"Times New Roman";}
+p
+	{mso-margin-top-alt:auto;
+	margin-right:0in;
+	mso-margin-bottom-alt:auto;
+	margin-left:0in;
+	mso-pagination:widow-orphan;
+	font-size:12.0pt;
+	font-family:"Times New Roman";
+	mso-fareast-font-family:"Times New Roman";}
+@page Section1
+	{size:8.5in 11.0in;
+	margin:1.0in 1.25in 1.0in 1.25in;
+	mso-header-margin:.5in;
+	mso-footer-margin:.5in;
+	mso-paper-source:0;}
+div.Section1
+	{page:Section1;}
+-->
+</style>
+<!--[if gte mso 10]>
+<style>
+ /* Style Definitions */
+ table.MsoNormalTable
+	{mso-style-name:"Table Normal";
+	mso-tstyle-rowband-size:0;
+	mso-tstyle-colband-size:0;
+	mso-style-noshow:yes;
+	mso-style-parent:"";
+	mso-padding-alt:0in 5.4pt 0in 5.4pt;
+	mso-para-margin:0in;
+	mso-para-margin-bottom:.0001pt;
+	mso-pagination:widow-orphan;
+	font-size:10.0pt;
+	font-family:"Times New Roman";}
+</style>
+<![endif]-->
+<meta name=CREATED content="20070703;53381">
+<meta name=CHANGEDBY content="a a">
+<meta name=CHANGED content="20070703;190294">
 <!-- <pre><a name="header-text">Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
@@ -25,50 +102,87 @@
 under the License.   </a></pre>
 
 -->
+</head>
+
+<body lang=EN-US style='tab-interval:.5in'>
+
+<div class=Section1>
+
+<h1><span lang=PT-BR style='mso-ansi-language:PT-BR'>DAS Samples<o:p></o:p></span></h1>
+
+<p><span lang=PT-BR style='mso-ansi-language:PT-BR'>The DAS Java Samples
+demonstrates the DAS features and how to get started with them. Below a list of
+available samples:<o:p></o:p></span></p>
+
+<table class=MsoNormalTable border=1 cellspacing=3 cellpadding=0 width="100%"
+ style='width:100.0%;mso-cellspacing:2.2pt;mso-padding-alt:3.0pt 3.0pt 3.0pt 3.0pt'>
+ <COL WIDTH=42*><COL WIDTH=214*>
+ <tr style='mso-yfti-irow:0'>
+  <td width="17%" valign=top style='width:17.0%;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
+  <h1 align=center style='margin-top:0in;text-align:center'><span lang=PT-BR
+  style='font-size:12.0pt;mso-ansi-language:PT-BR'>Company-webapp</span><span
+  lang=PT-BR style='mso-ansi-language:PT-BR'><o:p></o:p></span></h1>
+  </td>
+  <td width="83%" valign=top style='width:83.0%;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
+  <p><span lang=PT-BR style='mso-ansi-language:PT-BR'>This stand-alone sample
+  demonstrates DAS in the context of a simple web application. <o:p></o:p></span></p>
+  </td>
+ </tr>
+ <tr style='mso-yfti-irow:1'>
+  <td width="17%" valign=top style='width:17.0%;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
+  <h1 align=center style='margin-top:0in;text-align:center'><span lang=PT-BR
+  style='font-size:12.0pt;mso-ansi-language:PT-BR'>Customer </span><span
+  lang=PT-BR style='mso-ansi-language:PT-BR'><o:p></o:p></span></h1>
+  </td>
+  <td width="83%" valign=top style='width:83.0%;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
+  <p><span lang=PT-BR style='mso-ansi-language:PT-BR'>This stand-alone sample
+  demonstrates DAS in the context of a simple java application. <o:p></o:p></span></p>
+  </td>
+ </tr>
+ <tr style='mso-yfti-irow:2'>
+  <td width="17%" valign=top style='width:17.0%;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
+  <p align=center style='text-align:center'><b><span lang=PT-BR
+  style='mso-ansi-language:PT-BR'>Advanced-webapp</span></b><span lang=PT-BR
+  style='mso-ansi-language:PT-BR'> <o:p></o:p></span></p>
+  </td>
+  <td width="83%" valign=top style='width:83.0%;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
+  <p><span lang=PT-BR style='mso-ansi-language:PT-BR'>This web sample
+  demonstrates DAS advanced features in the context of a simple web application
+  using Ajax. Some of the features demonstrated are : Basic CRUD, Optimistic
+  Concurrency Control (OCC), Result Set Shape, Column Converter, Integration
+  with dbConfig <o:p></o:p></span></p>
+  </td>
+ </tr>
+ <tr style='mso-yfti-irow:3'>
+  <td width="17%" valign=top style='width:17.0%;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
+  <p align=center style='text-align:center'><b><span lang=PT-BR
+  style='mso-ansi-language:PT-BR'>Transaction<o:p></o:p></span></b></p>
+  </td>
+  <td width="83%" valign=top style='width:83.0%;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
+  <p><span lang=PT-BR style='mso-ansi-language:PT-BR'>This stand-alone sample
+  uses DAS with Geronimo Transaction Manager. Connection is passed to DAS by
+  client. Geronimo TM manages database changes involving multiple DataGraphs
+  under one transaction.<o:p></o:p></span></p>
+  </td>
+ </tr>
+ <tr style='mso-yfti-irow:4;mso-yfti-lastrow:yes'>
+  <td width="17%" valign=top style='width:17.0%;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
+  <p align=center style='text-align:center'><b><span lang=PT-BR
+  style='mso-ansi-language:PT-BR'>DataSource<o:p></o:p></span></b></p>
+  </td>
+  <td width="83%" valign=top style='width:83.0%;padding:3.0pt 3.0pt 3.0pt 3.0pt'>
+  <p><span lang=PT-BR style='mso-ansi-language:PT-BR'>This stand-alone sample
+  uses DAS with com.mysql.jdbc.jdbc2.optional.MysqlDataSource to demonstrate
+  DAS using dataSource.getConnection(id, pwd) - authentication information
+  passed in.<o:p></o:p></span></p>
+  </td>
+ </tr>
+</table>
+
+<p class=MsoNormal><o:p>&nbsp;</o:p></p>
+
+</div>
+
+</body>
 
-</HEAD>
-<BODY LANG="en-US" DIR="LTR">
-<H1 LANG="pt-BR">DAS Samples</H1>
-<P LANG="pt-BR"><FONT FACE="Times New Roman, serif">The DAS Java
-Samples demonstrates the DAS features and how to get started with
-them. Below a list of available samples:</FONT></P>
-<TABLE WIDTH=100% BORDER=1 CELLPADDING=4 CELLSPACING=3>
-	<COL WIDTH=42*>
-	<COL WIDTH=214*>
-	<TR VALIGN=TOP>
-		<TD WIDTH=17%>
-			<H1 LANG="pt-BR" ALIGN=CENTER STYLE="margin-top: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=3>Company-webapp</FONT></FONT></H1>
-		</TD>
-		<TD WIDTH=83%>
-			<P LANG="pt-BR"><FONT FACE="Times New Roman, serif" SIZE=3>This stand-alone sample demonstrates DAS in the context of a simple web application. </FONT>
-			</P>
-		</TD>
-	</TR>
-	<TR VALIGN=TOP>
-		<TD WIDTH=17%>
-			<H1 LANG="pt-BR" ALIGN=CENTER STYLE="margin-top: 0cm"><FONT FACE="Times New Roman, serif"><FONT SIZE=3>Customer
-			</FONT></FONT>
-			</H1>
-		</TD>
-		<TD WIDTH=83%>
-			<P LANG="pt-BR"><FONT FACE="Times New Roman, serif" SIZE=3>This stand-alone sample demonstrates DAS in the context of a simple java application. </FONT>
-			</P>
-		</TD>
-	</TR>
-	<TR VALIGN=TOP>
-		<TD WIDTH=17%>
-			<P LANG="pt-BR" ALIGN=CENTER><FONT FACE="Times New Roman, serif"><FONT SIZE=3><B>Advanced-webapp</B>
-			<B>DAS Web</B> </FONT></FONT>
-			</P>
-		</TD>
-		<TD WIDTH=83%>
-			<P LANG="pt-BR"><FONT FACE="Times New Roman, serif"><FONT SIZE=3>This web sample demonstrates DAS advanced features in the
-			context of a simple web application using Ajax. Some of the features demonstrated are :
-			Basic CRUD, Optimistic Concurrency Control (OCC), Result Set Shape, Column Converter,
-			Integration with dbConfig</FONT>
-			</P>
-		</TD>
-	</TR>
-</TABLE>
-</BODY>
-</HTML>
\ No newline at end of file
+</html>

Added: incubator/tuscany/java/das/samples/dataSource/build.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/dataSource/build.xml?rev=591886&view=auto
==============================================================================
--- incubator/tuscany/java/das/samples/dataSource/build.xml (added)
+++ incubator/tuscany/java/das/samples/dataSource/build.xml Sun Nov  4 21:53:43 2007
@@ -0,0 +1,42 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+-->
+<project name="dataSource" default="run">
+    <property name="test.class" value="org.apache.tuscany.samples.das.dataSource.ViewBooks" />
+	<property name="test.jar"   value="sample-dataSource.jar" />
+	
+	
+    <target name="run">
+        <java classname="${test.class}"
+              fork="true">
+       	<arg value="connectionInfoDataSourceAuth.xml"/>
+       	<arg value="dastest"/>
+        <arg value="com.sun.jndi.fscontext.RefFSContextFactory"/>
+	    <classpath>
+	      <pathelement path="${classpath}"/>
+	      <fileset dir="../../lib">
+		<include name="**/*.jar"/>
+	      </fileset>
+		<pathelement location="mysql-connector-java-5.0.4.jar"/>
+		<pathelement path="${test.jar}"/>
+	    </classpath>        
+        </java>    	
+    </target>	
+	
+</project>
+

Added: incubator/tuscany/java/das/samples/dataSource/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/dataSource/pom.xml?rev=591886&view=auto
==============================================================================
--- incubator/tuscany/java/das/samples/dataSource/pom.xml (added)
+++ incubator/tuscany/java/das/samples/dataSource/pom.xml Sun Nov  4 21:53:43 2007
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.das.samples</groupId>
+        <artifactId>tuscany-das-samples</artifactId>
+        <version>1.0-incubating-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>tuscany-das-sample-dataSource</artifactId>
+    <packaging>jar</packaging>
+    <name>Tuscany DAS J2SE DataSource Sample to use DataSource with authentication</name>
+    <description>Sample use of RDB DAS in a J2SE application with DataSource</description>
+
+    <dependencies>
+       <dependency>
+           <groupId>org.apache.tuscany.das</groupId>
+           <artifactId>tuscany-das-rdb</artifactId>
+           <version>${das.version}</version>
+           <scope>compile</scope>
+       </dependency>
+
+       <dependency>
+           <groupId>org.apache.tuscany.sdo</groupId>
+           <artifactId>tuscany-sdo-impl</artifactId>
+           <version>${sdo.version}</version>
+           <scope>compile</scope>
+       </dependency>
+
+       <dependency>
+           <groupId>org.apache.tuscany.sdo</groupId>
+           <artifactId>tuscany-sdo-api-r2.1</artifactId>
+           <version>${sdo.version}</version>
+           <scope>compile</scope>
+       </dependency>
+          
+	  <dependency>
+	     <groupId>mysql</groupId>
+	     <artifactId>mysql-connector-java</artifactId>
+	     <version>5.0.4</version>
+	     <scope>compile</scope>
+	  </dependency>
+	 
+    </dependencies>
+
+    <!-- this will place the java source files inside the jar -->
+    <build>
+        <finalName>sample-dataSource</finalName>
+        <sourceDirectory>src/main/java</sourceDirectory>
+        <resources>
+            <resource>
+                <directory>src/main/java</directory>
+            </resource>
+            <resource>
+              <directory>src/main/resources</directory>
+            </resource>
+        </resources>
+	   <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest> 
+                    <mainClass>org.apache.tuscany.samples.das.dataSource.ViewBooks</mainClass> 
+                    <addClasspath>true</addClasspath> 
+                    <!-- classpathPrefix>../../lib/</classpathPrefix --> 
+                   </manifest> 
+
+                    </archive>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: incubator/tuscany/java/das/samples/dataSource/readme.htm
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/dataSource/readme.htm?rev=591886&view=auto
==============================================================================
--- incubator/tuscany/java/das/samples/dataSource/readme.htm (added)
+++ incubator/tuscany/java/das/samples/dataSource/readme.htm Sun Nov  4 21:53:43 2007
@@ -0,0 +1,301 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html xmlns:o="urn:schemas-microsoft-com:office:office"
+xmlns:w="urn:schemas-microsoft-com:office:word"
+xmlns="http://www.w3.org/TR/REC-html40">
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
+<meta name=ProgId content=Word.Document>
+<meta name=Generator content="Microsoft Word 10">
+<meta name=Originator content="Microsoft Word 10">
+<link rel=File-List href="readme_files/filelist.xml">
+<title>Tuscany RDB DAS Sample</title>
+<!--[if gte mso 9]><xml>
+ <o:DocumentProperties>
+  <o:Author>IBM_User</o:Author>
+  <o:LastAuthor>IBM_USER</o:LastAuthor>
+  <o:Revision>77</o:Revision>
+  <o:TotalTime>374</o:TotalTime>
+  <o:Created>2007-09-05T11:09:00Z</o:Created>
+  <o:LastSaved>2007-11-02T19:30:00Z</o:LastSaved>
+  <o:Pages>1</o:Pages>
+  <o:Words>330</o:Words>
+  <o:Characters>1883</o:Characters>
+  <o:Company>IBM</o:Company>
+  <o:Lines>15</o:Lines>
+  <o:Paragraphs>4</o:Paragraphs>
+  <o:CharactersWithSpaces>2209</o:CharactersWithSpaces>
+  <o:Version>10.6830</o:Version>
+ </o:DocumentProperties>
+</xml><![endif]--><!--[if gte mso 9]><xml>
+ <w:WordDocument>
+  <w:Compatibility>
+   <w:ApplyBreakingRules/>
+  </w:Compatibility>
+  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
+ </w:WordDocument>
+</xml><![endif]-->
+<style>
+<!--
+ /* Font Definitions */
+ @font-face
+	{font-family:SimSun;
+	panose-1:2 1 6 0 3 1 1 1 1 1;
+	mso-font-alt:\5B8B\4F53;
+	mso-font-charset:134;
+	mso-generic-font-family:auto;
+	mso-font-pitch:variable;
+	mso-font-signature:3 135135232 16 0 262145 0;}
+@font-face
+	{font-family:"\@SimSun";
+	panose-1:2 1 6 0 3 1 1 1 1 1;
+	mso-font-charset:134;
+	mso-generic-font-family:auto;
+	mso-font-pitch:variable;
+	mso-font-signature:3 135135232 16 0 262145 0;}
+ /* Style Definitions */
+ p.MsoNormal, li.MsoNormal, div.MsoNormal
+	{mso-style-parent:"";
+	margin:0in;
+	margin-bottom:.0001pt;
+	mso-pagination:widow-orphan;
+	font-size:12.0pt;
+	font-family:"Times New Roman";
+	mso-fareast-font-family:SimSun;}
+h1
+	{mso-margin-top-alt:auto;
+	margin-right:0in;
+	mso-margin-bottom-alt:auto;
+	margin-left:0in;
+	mso-pagination:widow-orphan;
+	mso-outline-level:1;
+	font-size:24.0pt;
+	font-family:"Times New Roman";
+	mso-fareast-font-family:"Times New Roman";
+	font-weight:bold;}
+h2
+	{mso-margin-top-alt:auto;
+	margin-right:0in;
+	mso-margin-bottom-alt:auto;
+	margin-left:0in;
+	mso-pagination:widow-orphan;
+	mso-outline-level:2;
+	font-size:18.0pt;
+	font-family:"Times New Roman";
+	mso-fareast-font-family:"Times New Roman";
+	font-weight:bold;}
+a:link, span.MsoHyperlink
+	{color:blue;
+	text-decoration:underline;
+	text-underline:single;}
+a:visited, span.MsoHyperlinkFollowed
+	{color:blue;
+	text-decoration:underline;
+	text-underline:single;}
+p
+	{mso-margin-top-alt:auto;
+	margin-right:0in;
+	mso-margin-bottom-alt:auto;
+	margin-left:0in;
+	mso-pagination:widow-orphan;
+	font-size:12.0pt;
+	font-family:"Times New Roman";
+	mso-fareast-font-family:SimSun;}
+@page Section1
+	{size:8.5in 11.0in;
+	margin:1.0in 1.25in 1.0in 1.25in;
+	mso-header-margin:.5in;
+	mso-footer-margin:.5in;
+	mso-paper-source:0;}
+div.Section1
+	{page:Section1;}
+-->
+</style>
+<!--[if gte mso 10]>
+<style>
+ /* Style Definitions */
+ table.MsoNormalTable
+	{mso-style-name:"Table Normal";
+	mso-tstyle-rowband-size:0;
+	mso-tstyle-colband-size:0;
+	mso-style-noshow:yes;
+	mso-style-parent:"";
+	mso-padding-alt:0in 5.4pt 0in 5.4pt;
+	mso-para-margin:0in;
+	mso-para-margin-bottom:.0001pt;
+	mso-pagination:widow-orphan;
+	font-size:10.0pt;
+	font-family:"Times New Roman";}
+</style>
+<![endif]-->
+<meta name=CREATED content="20070704;1002817">
+<meta name=CHANGEDBY content="a a">
+<meta name=CHANGED content="20070704;2123396">
+<!-- <pre><a name="header-text">Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+&quot;License&quot;); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+&quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.   </a></pre>
+
+-->
+</head>
+
+<body lang=EN-US link=blue vlink=blue style='tab-interval:.5in'>
+
+<div class=Section1>
+
+<h1 style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>RDB DAS Data Source Sample<o:p></o:p></span></h1>
+
+<h2 style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'><o:p>&nbsp;</o:p></span></h2>
+
+<h2 style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>Introduction<o:p></o:p></span></h2>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>This stand-alone sample demonstrates the RDB Data Access Service using
+DataSource with authentication information from DAS Config. <o:p></o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><b><span lang=PT-BR
+style='mso-ansi-language:PT-BR'><o:p>&nbsp;</o:p></span></b></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><b><span lang=PT-BR
+style='font-size:18.0pt;mso-ansi-language:PT-BR'>Example</span></b><span
+lang=PT-BR style='font-size:18.0pt;mso-ansi-language:PT-BR'><o:p></o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>In this example, user is expected to have JNDI provider jars in the classpath
+e.g. fscontext.jar and providerutil.jar from <a href="http://java.sun.com/">http://java.sun.com</a>.<o:p></o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR;mso-bidi-font-weight:bold'>Three arguments expected in sequence are 1)
+DAS Config file name available in source path,<span style='mso-spacerun:yes'> 
+</span>2) database name, 3) INITIAL_CONTEXT_FACTORY e.g. <b>com.sun.jndi.fscontext.RefFSContextFactory.
+</b>These<o:p></o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR;mso-bidi-font-weight:bold'>Are provided in build.xml ant script that
+comes along with the sample.<o:p></o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><b><span lang=PT-BR
+style='mso-ansi-language:PT-BR'><o:p>&nbsp;</o:p></span></b></p>
+
+<h2 style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>Building and Running<o:p></o:p></span></h2>
+
+<p style='margin:0in;margin-bottom:.0001pt'><b><span lang=PT-BR
+style='mso-ansi-language:PT-BR'><span style='mso-spacerun:yes'> </span></span></b><span
+lang=PT-BR style='mso-ansi-language:PT-BR'>From binary distribution, <b>base
+directory</b> is {DAS_ROOT}\ samples\dataSource. Refer to below settings from
+this base directory.<o:p></o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>1] connectionInfoDataSourceAuth.xml available in sample-dataSource.jar,
+is the DAS config file. <span style='mso-spacerun:yes'> </span>It references a
+MySQL database name “dastest” and authentication info – root/mypwd. User can
+expand<o:p></o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>the sample and change the xml file to suit his environment – like database
+name, id, pwd. He needs to do consistent changes in {DAS_ROOT}\
+samples\dataSource\build.xml for input arguments too.<o:p></o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'><o:p>&nbsp;</o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>2]MySQL server should be running. The example uses MySQL DB. Database <b>dastest,
+</b>table <b>BOOK </b>and data will be created during sample run. <o:p></o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'><o:p>&nbsp;</o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>3] Apache Ant latest version should be installed.Download Apache Ant
+latest version on and extract into folder &lt;apache_ant_folder&gt;. You can
+find it here: <a href="http://ant.apache.org/bindownload.cgi">http://ant.apache.org/bindownload.cgi</a>.Add
+&lt;apache_ant_folder&gt;/bin directory to your OS path variable.<o:p></o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'><o:p>&nbsp;</o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>4]<span style='mso-spacerun:yes'>  </span>Place required JNDI jar files
+in {DAS_ROOT}\ lib<o:p></o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'><o:p>&nbsp;</o:p></span></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>5] From <b>base directory </b>run-<span style='mso-spacerun:yes'> 
+</span>ant<o:p></o:p></span></p>
+
+<h2 style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='font-size:
+12.0pt;mso-ansi-language:PT-BR;font-weight:normal;mso-bidi-font-weight:bold'><o:p>&nbsp;</o:p></span></h2>
+
+<h2 style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='font-size:
+12.0pt;mso-ansi-language:PT-BR;font-weight:normal;mso-bidi-font-weight:bold'>The
+sample first creates and initilizes DataSource for database “dastest”. It also
+registers the DataSource in InitialContext. In the test part, DAS Config is
+used by DAS runtime to obtain connection based on<o:p></o:p></span></h2>
+
+<h2 style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='font-size:
+12.0pt;mso-ansi-language:PT-BR;font-weight:normal;mso-bidi-font-weight:bold'>DataSource
+available in InitialContext using userId, password. <span
+style='mso-spacerun:yes'> </span>Using this connection it fetches and displays
+data from BOOK table.<o:p></o:p></span></h2>
+
+<h2 style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='font-size:
+12.0pt;mso-ansi-language:PT-BR;font-weight:normal;mso-bidi-font-weight:bold'><o:p>&nbsp;</o:p></span></h2>
+
+<p style='margin:0in;margin-bottom:.0001pt'><span lang=PT-BR style='mso-ansi-language:
+PT-BR'>The sample will run and output the following: <o:p></o:p></span></p>
+
+<div style='border:solid windowtext 1.0pt;mso-border-alt:solid windowtext .5pt;
+padding:1.0pt 4.0pt 1.0pt 4.0pt'>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none;
+border:none;mso-border-alt:solid windowtext .5pt;padding:0in;mso-padding-alt:
+1.0pt 4.0pt 1.0pt 4.0pt'><span style='font-size:10.0pt;font-family:"Courier New";
+mso-fareast-font-family:"Times New Roman";color:black'>Books in store:1</span><span
+style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman"'><o:p></o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none;
+border:none;mso-border-alt:solid windowtext .5pt;padding:0in;mso-padding-alt:
+1.0pt 4.0pt 1.0pt 4.0pt'><span style='font-size:10.0pt;font-family:"Courier New";
+mso-fareast-font-family:"Times New Roman";color:black'>1<span
+style='mso-spacerun:yes'>    </span>StoryBook1</span><span style='font-size:
+10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman"'><o:p></o:p></span></p>
+
+<p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none;
+border:none;mso-border-alt:solid windowtext .5pt;padding:0in;mso-padding-alt:
+1.0pt 4.0pt 1.0pt 4.0pt'><span style='font-size:10.0pt;font-family:"Courier New";
+mso-fareast-font-family:"Times New Roman";color:black'>Success!</span><span
+style='font-size:10.0pt;font-family:"Courier New";mso-fareast-font-family:"Times New Roman"'><o:p></o:p></span></p>
+
+</div>
+
+<p style='margin:0in;margin-bottom:.0001pt'><o:p>&nbsp;</o:p></p>
+
+<p style='margin:0in;margin-bottom:.0001pt'><b><span lang=PT-BR
+style='mso-ansi-language:PT-BR'>Observation:</span></b><span lang=PT-BR
+style='mso-ansi-language:PT-BR'> The build.xml ant file only works on DAS Java
+binary distribution.<o:p></o:p></span></p>
+
+</div>
+
+</body>
+
+</html>

Added: incubator/tuscany/java/das/samples/dataSource/src/main/java/org/apache/tuscany/samples/das/dataSource/ViewBooks.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/dataSource/src/main/java/org/apache/tuscany/samples/das/dataSource/ViewBooks.java?rev=591886&view=auto
==============================================================================
--- incubator/tuscany/java/das/samples/dataSource/src/main/java/org/apache/tuscany/samples/das/dataSource/ViewBooks.java (added)
+++ incubator/tuscany/java/das/samples/dataSource/src/main/java/org/apache/tuscany/samples/das/dataSource/ViewBooks.java Sun Nov  4 21:53:43 2007
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.samples.das.dataSource;
+
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.das.rdb.ConfigHelper;
+import org.apache.tuscany.das.rdb.DAS;
+
+import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
+import commonj.sdo.DataObject;
+
+public class ViewBooks {
+	ConfigHelper configHelper = null;
+	
+	public static void main(String[] args) throws Exception {
+		if(args == null || args.length != 3 ) {
+			System.out.println("Usage: java ViewBooks configFileName databaseName JNDIProviderFactory");
+			System.exit(-1);
+		}
+		
+		String configFileName = args[0];
+		String databaseName = args[1];
+		String JNDIProviderName = args[2];
+		
+		ViewBooks vb = new ViewBooks(configFileName);
+		vb.bindAndcreateDataSource(databaseName, JNDIProviderName);
+		vb.viewBooks();
+	}
+	
+	protected ViewBooks(String configFileName) {
+		configHelper = new ConfigHelper(getConfig(configFileName));
+	}
+	
+    protected void bindAndcreateDataSource(String databaseName, String contextFactoryPath) throws Exception {
+    	System.setProperty(Context.INITIAL_CONTEXT_FACTORY, contextFactoryPath);//"com.sun.jndi.fscontext.RefFSContextFactory"
+		InitialContext initCtx = new InitialContext();		
+		MysqlDataSource ds = new MysqlDataSource();
+		ds.setCreateDatabaseIfNotExist(true);
+		ds.setDatabaseName(databaseName);
+		String urlStr = "jdbc:mysql://localhost/"+databaseName;
+		ds.setUrl(urlStr);
+		ds.setURL(urlStr);
+				
+		String userName = configHelper.getConfig().getConnectionInfo().getConnectionProperties().getUserName();
+		String password = configHelper.getConfig().getConnectionInfo().getConnectionProperties().getPassword();
+		String dataSource = configHelper.getConfig().getConnectionInfo().getDataSource();
+		
+		ds.setPassword(password);
+		ds.setUser(userName);
+		try{
+			initCtx.rebind(dataSource, (javax.sql.DataSource)ds);
+		}catch(NamingException ne){
+			initCtx.bind(dataSource, (javax.sql.DataSource)ds);	
+		}
+		
+		Connection con = ds.getConnection(userName, password);
+		Statement stmt = con.createStatement();
+		try {
+			stmt.executeQuery("select * from BOOK");
+			stmt.execute("delete from BOOK");
+		} catch(SQLException sqe) {
+			try {
+				stmt.execute("create table BOOK (ID int, NAME varchar(30))");
+			} catch(SQLException e) {
+				e.printStackTrace();
+				//ignore
+			}
+		} finally {
+			try {
+				stmt.execute("insert into BOOK values (1, 'StoryBook1')");
+			} catch(SQLException e) {
+				e.printStackTrace();
+				//ignore
+			}			
+		}
+    }
+    
+    /*As database is created with id/pwd, when same is used when getting DS Connection, works correct*/
+    protected void viewBooks() throws Exception {
+   		try {
+	   		DAS das = DAS.FACTORY.createDAS(configHelper.getConfig());
+	   		DataObject root = das.getCommand("getBook").executeQuery();
+	   		List books = root.getList("BOOK");
+	   		
+	   		System.out.println("Books in store:"+books.size());
+	   		System.out.println( ((DataObject)books.get(0)).getInt(0)+"    "+((DataObject)books.get(0)).getString(1));
+	   		System.out.println("Success!");
+   		} catch(Exception e) {
+   			e.printStackTrace();
+   		}
+    }
+    
+    protected InputStream getConfig(String fileName) {
+        return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
+    }
+}

Added: incubator/tuscany/java/das/samples/dataSource/src/main/resources/connectionInfoDataSourceAuth.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/dataSource/src/main/resources/connectionInfoDataSourceAuth.xml?rev=591886&view=auto
==============================================================================
--- incubator/tuscany/java/das/samples/dataSource/src/main/resources/connectionInfoDataSourceAuth.xml (added)
+++ incubator/tuscany/java/das/samples/dataSource/src/main/resources/connectionInfoDataSourceAuth.xml Sun Nov  4 21:53:43 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd" > 
+ 
+<ConnectionInfo dataSource="java/dastestcon">
+    <ConnectionProperties
+        userName="root"
+        password="mypwd"        
+        loginTimeout="600000"/>
+</ConnectionInfo>
+
+<Command name="getBook" SQL="Select * from BOOK" kind="Select"/>
+
+</Config>

Modified: incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBConnectionHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBConnectionHelper.java?rev=591886&r1=591885&r2=591886&view=diff
==============================================================================
--- incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBConnectionHelper.java (original)
+++ incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBConnectionHelper.java Sun Nov  4 21:53:43 2007
@@ -6,15 +6,15 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 
 package org.apache.tuscany.das.rdb.dbconfig;
@@ -32,16 +32,16 @@
 
 public class DBConnectionHelper {
 	private static final Logger logger = Logger.getLogger(DBConnectionHelper.class);
-	
+
 	protected DBConnectionHelper(){
         if(logger.isDebugEnabled()) {
             logger.log(Level.DEBUG, "DBConnectionHelper()");
         }
 	}
-    
+
     /**
-     * Basic validation of Config for connection information and call to 
-     * connection helper to establish database connection. Connection using 
+     * Basic validation of Config for connection information and call to
+     * connection helper to establish database connection. Connection using
      * DriverManager or DataSource are supported.
      *
      */
@@ -49,26 +49,29 @@
         if (logger.isDebugEnabled()) {
             logger.log(Level.DEBUG, "DBConnectionHelper.createConnection(ConnectionInfo)");
         }
-        
-        if (connectionInfo == null || 
-            (connectionInfo.getDataSource() == null && connectionInfo.getConnectionProperties() == null)) {
-            throw new RuntimeException("No connection has been provided and no data source has been specified");
+
+        if (connectionInfo == null ||
+                (connectionInfo.getDataSource() == null &&
+                		(connectionInfo.getConnectionProperties() == null || connectionInfo.getConnectionProperties().getDatabaseURL() == null
+                		|| connectionInfo.getConnectionProperties().getDriverClass() == null)) ) {
+                throw new RuntimeException("No connection has been provided and no data source has been specified");
         }
 
-        if(connectionInfo.getDataSource() != null && connectionInfo.getConnectionProperties() != null){
-            throw new RuntimeException("Use either dataSource or ConnectionProperties. Can't use both !");
+        if(connectionInfo.getDataSource() != null &&
+        		(connectionInfo.getConnectionProperties() != null && connectionInfo.getConnectionProperties().getDatabaseURL() != null) ){
+            throw new RuntimeException("Use either dataSource or databaseURL. Can't use both !");
         }
-        
+
         Connection connection = null;
-        
-        if(connectionInfo.getConnectionProperties() != null){
-            connection = initializeDriverManagerConnection(connectionInfo);
+
+        if(connectionInfo.getDataSource() != null){
+        	connection = initializeDatasourceConnection(connectionInfo);
         }else{
-            connection = initializeDatasourceConnection(connectionInfo);
+        	connection = initializeDriverManagerConnection(connectionInfo);
         }
-        
+
         return connection;
-        
+
     }
     /**
      * Initializes a DB connection on a managed environmet (e.g inside Tomcat)
@@ -77,10 +80,10 @@
         if (logger.isDebugEnabled()) {
             logger.log(Level.DEBUG, "DBConnectionHelper.initializeDatasourceConnection(ConnectionInfo)");
         }
-        
+
         InitialContext ctx;
         Connection connection;
-        
+
         try {
             ctx = new InitialContext();
         } catch (NamingException e) {
@@ -89,12 +92,23 @@
         try {
             DataSource ds = (DataSource) ctx.lookup(connectionInfo.getDataSource());
             try {
-                connection = ds.getConnection();
+            	try {
+	            	if(connectionInfo.getConnectionProperties() != null &&
+	            	   connectionInfo.getConnectionProperties().getUserName() != null &&
+	            	   connectionInfo.getConnectionProperties().getPassword() != null ) {
+	            		connection = ds.getConnection(connectionInfo.getConnectionProperties().getUserName(), connectionInfo.getConnectionProperties().getPassword());
+	            	} else {
+	            		connection = ds.getConnection();
+	            	}
+            	}catch(Exception e) {
+            		connection = ds.getConnection();
+            	}
+
                 if (connection == null) {
                     throw new RuntimeException("Could not obtain a Connection from DataSource");
                 }
                 connection.setAutoCommit(true);
-                
+
             } catch (SQLException e) {
                 throw new RuntimeException(e);
             }
@@ -107,7 +121,7 @@
         }
         return connection;
     }
-    
+
     /**
      * Initialize a DB connection on a J2SE environment
      * For more info, see http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/drivermanager.html
@@ -116,7 +130,7 @@
 		if (logger.isDebugEnabled()) {
 		    logger.log(Level.DEBUG, "DBConnectionHelper.initializeDriverManagerConnection(ConnectionInfo)");
         }
-    	
+
         if (connectionInfo.getConnectionProperties() == null) {
             throw new DataSourceInitializationException("No existing context and no connection properties");
         }
@@ -126,17 +140,17 @@
         }
 
         Connection connection;
-        
+
         try {
             //initialize driver and register it with DriverManager
             Class.forName(connectionInfo.getConnectionProperties().getDriverClass());
-            
+
             //prepare to initialize connection
             String databaseUrl = connectionInfo.getConnectionProperties().getDatabaseURL();
             String userName = connectionInfo.getConnectionProperties().getUserName();
             String userPassword = connectionInfo.getConnectionProperties().getPassword();
             int loginTimeout = connectionInfo.getConnectionProperties().getLoginTimeout();
-            
+
             DriverManager.setLoginTimeout(loginTimeout);
             if( (userName == null || userName.length() ==0) && (userPassword == null || userPassword.length()==0) ){
                 //no username or password suplied
@@ -144,22 +158,22 @@
             }else{
                 connection = DriverManager.getConnection(databaseUrl, userName, userPassword);
             }
-            
+
             if(connection == null){
                 throw new DataSourceInitializationException("Error initializing connection : null");
             }
-            
+
             connection.setAutoCommit(true);
         }catch(ClassNotFoundException cnf){
             throw new DataSourceInitializationException("JDBC Driver '" + connectionInfo.getConnectionProperties().getDriverClass() + "' not found", cnf);
         }catch(SQLException sqle){
             throw new DataSourceInitializationException(sqle.getMessage(), sqle);
         }
-        
+
         if (logger.isDebugEnabled()) {
             logger.log(Level.DEBUG, "DBConnectionHelper.initializeDriverManagerConnection() exit");
         }
-        
+
         return connection;
     }
 }

Modified: incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBHelper.java?rev=591886&r1=591885&r2=591886&view=diff
==============================================================================
--- incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBHelper.java (original)
+++ incubator/tuscany/java/das/samples/dbconfig/src/main/java/org/apache/tuscany/das/rdb/dbconfig/DBHelper.java Sun Nov  4 21:53:43 2007
@@ -6,15 +6,15 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
- * under the License.    
+ * under the License.
  */
 
 package org.apache.tuscany.das.rdb.dbconfig;
@@ -37,7 +37,7 @@
 
     /**
      * Constructor
-     * 
+     *
      * @param DBConfig
      */
     protected DBHelper(DBConfig dbConfig) {
@@ -49,7 +49,7 @@
 
     /**
      * Check if tables specified in Config exist
-     * 
+     *
      * @return true if all specified tables exist, false otherwise
      */
     protected boolean isDatabaseReady() {
@@ -77,12 +77,13 @@
                 }
             }
         } catch (SQLException e) {
+        	bResult = false;
             if (logger.isDebugEnabled()) {
                 this.logger.log(Level.DEBUG, "Error retrieving database metadata", e);
             }
         } finally {
             try {
-                dbConnection.close();
+                if(dbConnection != null) dbConnection.close();
             } catch (SQLException e) {
                 // ignore here
             }
@@ -91,7 +92,7 @@
         if (logger.isDebugEnabled()) {
             this.logger.log(Level.DEBUG, CLASS_NAME + "isDatabaseReady() exit");
         }
-        
+
         return bResult;
     }
 
@@ -184,7 +185,7 @@
             try {
                 if(dbStatement != null)
                 	dbStatement.close();
-                
+
                 if(dbConnection != null)
                 	dbConnection.close();
             } catch (SQLException e) {

Modified: incubator/tuscany/java/das/samples/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/pom.xml?rev=591886&r1=591885&r2=591886&view=diff
==============================================================================
--- incubator/tuscany/java/das/samples/pom.xml (original)
+++ incubator/tuscany/java/das/samples/pom.xml Sun Nov  4 21:53:43 2007
@@ -36,5 +36,6 @@
         <module>advanced-webapp</module>
         <module>customer</module>
         <module>transaction</module>
+        <module>dataSource</module>
     </modules>
 </project>



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org