Java Reference
In-Depth Information
<dataSource name="Northwind"
connectionString="server=localhost,1403;database=Northwind;
user id=sa;password=sa;connection reset=false;connection
lifetime=5;min pool size=1; max pool size=50"/>
</database>
<sqlMaps>
<sqlMap resource="Employee.xml"/>
</sqlMaps>
</sqlMapConfig>
If you're familiar with i BATIS for Java, then the configuration file in listing A.1
should look somewhat familiar. It begins with a declaration of providers, which
are included configurations for various database drivers. The ADO.NET database
driver model requires a bit more initial setup than JDBC does. That configuration
is contained within the providers.config file, which is included with the i BA-
TIS.NET distribution. Notice that the database connectivity configuration is quite
different. It goes without saying that i BATIS.NET makes use of ADO.NET , whereas
Java uses JDBC . Each of these low-level API s uses different driver models and dif-
ferent connection strings—hence the difference in the structure of this part of
the XML . However, the configuration file maintains its simplicity. Usually, you
need only specify the provider, a data source name, and a connection string.
The provider tells i BATIS which kind of database you are connecting to. Pro-
viders are pluggable components of i BATIS.NET , and there is one for each data-
base type supported. However, you might want to look in providers.config and
disable or remove any providers that you don't have drivers for; otherwise, you'll
get an error if you try to run the application without them.
The database name and connection string set up a database connection using
the credentials and other information that you provide (e.g., username and pass-
word). If you're used to Java, this is not unlike a typical JDBC connection URL .
The last part of the configuration file is the <sqlMaps> stanza, which lists all of
the SQL mapping files that contain the SQL statements, result maps, and other
i BATIS elements. In this example, we have only one mapping file, which is called
Employee.xml .
As you've probably noticed, these examples all make use of the Northwind
database included with Microsoft SQL Server and Microsoft Access. This database
is popular for sample code such as that listed throughout this appendix.
Search WWH ::




Custom Search