Apache Tuscany > Home > DAS Overview > DAS Java > DAS Java Documentation Menu > DAS Java Developer Guide > RDB DAS Java > RDB DAS - User Guide > Connection support for J2SE environment User List | Dev List | Issue Tracker  

Connection support for J2SE environment

So far DAS utilized JDBC Connection - either explicitly supplied by DAS invoker or available in the runtime context pre-configured using JNDI.

DAS config needs to have provision to support JDBC Connection for J2SE environment, when JNDI is not configured and connection is not explicitly supplied by the DAS invoker.

Below are the changes in DAS Config xsd. The attribute dataSource and element ConnectionProperties
are mutually exclusive. User needs to specify ONLY one of these. When ConnectionProperties is specified, DriverManager for appropriate database vendor is used to instantiate the JDBC Connection.
This way the J2SE applications can use DAS.

When dataSource is specified, the JNDI context is searched for pre-configured dataSource. This mode is useful, when Web Containers like Tomcat have the resource pre-defined for the dataSource.

   <xsd:complexType name="ConnectionProperties">
      <xsd:attribute name="driverClass" type="xsd:string"/>
      <xsd:attribute name="databaseURL" type="xsd:string"/>
      <xsd:attribute name="userName" type="xsd:string" default=""/>
      <xsd:attribute name="password" type="xsd:string" default=""/>
      <xsd:attribute name="loginTimeout" type="xsd:int" default="0"/>      
   </xsd:complexType>
   
   <xsd:complexType name="ConnectionInfo">
      <xsd:sequence>
        <xsd:element  maxOccurs="1" minOccurs="0" name="ConnectionProperties" type="config:ConnectionProperties"/>
      </xsd:sequence>
      <xsd:attribute name="dataSource" type="xsd:string"/>
      <xsd:attribute name="managedtx" type="xsd:boolean" default="true"/>
   </xsd:complexType>

Below is one example DAS config, using Derby database.

 <Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd"> 
    
    <!--Uncomment below for derby test-->
	<ConnectionInfo>
		<ConnectionProperties
			driverClass="org.apache.derby.jdbc.EmbeddedDriver"
			databaseURL="jdbc:derby:target/dastest; create = true"
			loginTimeout="600000"/>
	</ConnectionInfo>
   ....
  </Config>
website stats