| S2Container.NET TOP page ## Connecting to a Database S2Container.NET after version 1.1 supports database connection. When using S2Tx.NET, transaction is maintained even after connection is open and closed several times. Transaction may, also, be processed using Aspect. ## Setup Configure DataProvider and TxDataSource. ### Seasar.Extension.ADO.DataProvider
Property | Description | Example
--- | --- | ---
ConnectionType | Retrieve class name of .NET Framework data provider that implements System.Data.IDbConnection interface. Required | "System.Data.SqlClient.SqlConnection"
CommandType | Set class name of .NET Framework that implements System.Data.IDbCommand interface. Required | "System.Data.SqlClient.SqlCommand"
ParameterType | Set class name of .NET Framework data provider that implements System.Data.IDbParameter interface. Required | "System.Data.SqlClient.SqlParameter"
DataAdapterType | Set class name of .NET Framework data provider that implements System.Data.IDbDataAdapter interface. Required | "System.Data.SqlClient.SqlDataAdapter"
### Seasar.Extension.Tx.Impl.TxDataSource
Property | Description | Example
--- | --- | ---
DataProvider | Specify DataProvider instance name. When specifying from a S2Container, specify DataProvider component name. Required | SqlClient
ConnectionString | Connection string to connect to a database. String to set to System.Data.IDbConnection.ConnectionString. Required Note: Use "\\" to denote "\". For example, to connect to an instance of SQL Server 2005, use "computer name\\instance name". | "Server=MYPC\\SQLEXPRESS;database=s2dotnetdemo;Integrated Security=SSPI"
Component configuration is as follows: (Replace values to those on your environment.) Ado.dicon
    <components namespace="Ado">
      <component name="SqlClient" class="Seasar.Extension.ADO.DataProvider">
        <property name="ConnectionType">"System.Data.SqlClient.SqlConnection"</property>
        <property name="CommandType">"System.Data.SqlClient.SqlCommand"</property>
        <property name="ParameterType">"System.Data.SqlClient.SqlParameter"</property>
        <property name="DataAdapterType">"System.Data.SqlClient.SqlDataAdapter"</property>
      </component>

      <component name="DataSource" class="Seasar.Extension.Tx.Impl.TxDataSource">
        <property name="DataProvider">SqlClient</property>
        <property name="ConnectionString">"Server=(local);database=s2dotnetdemo;Integrated Security=SSPI"</property>
      </component>

      <component name="TransactionContext" class="Seasar.Extension.Tx.Impl.TransactionContext">
        <property name="IsolationLevel">System.Data.IsolationLevel.ReadCommitted</property>
      </component>
    </components>
### Application Configuration File To use .NET Framework data provider other than .NET Framework data provider for SQL Server, it is necessary to specify .NET Framework data provider assembly in <seasar> configuration section in the application configuration file. App.config
    <configuration>
      <configSections>
        <section name="seasar" type="Seasar.Framework.Xml.S2SectionHandler, Seasar" />
      </configSections>
      <seasar>
        <assemblys>
          <!-- needed when using .NET Framework Data Provider for Oracle -->
          <assembly>System.Data.OracleClient, version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</assembly>
          <!-- needed when using Firebird .NET Data Provider -->
          <!--
          <assembly>FirebirdSql.Data.Firebird, Version=1.7.0.1, Culture=neutral, PublicKeyToken=fa843d180294369d</assembly>
          -->
        </assemblys>
      </seasar>
    </configuration>
Trans. by H.Ozawa | Copyright© 2004-2007, The Seasar Foundation and the others. All rights reserved.