I just climbed the drums and came back. I thought that this is just beginning, I don't dare to neglect, take a shower and take a break. I will come to the computer. Now I start to introduce the IBATIS configuration and log processing.
IBATIS basic operating environment configuration is mainly composed of two files, named SQLMap.config and provider.config. They are the necessary two profiles, the functionality of SQLMap.config is similar to web.config or app.config, is the iBATIS core configuration file, which is also the same as the application configuration file, must be placed in the application The running directory and its file name is reserved, and it cannot be changed. And Provider.config is a data driver provides class configuration, and its file name is free to change because of a configuration section of SQLMap.config. You can configure it.
SQLMap.config includes the following major configuration segments, and some configuration segments are not required as needed:
1. Properties: You can configure some constant properties as needed. If these properties have a lot, you can write a file separately, then through Resource (or URL, Embedded is a reference URL and the resource file compiled in the program) attribute reference. Such as:
Properties>
This configuration section is optional.
2. Settings: including three configuration segments:
USSTATEMENTNAMESPACES: In the document, it means that it is configured to use the statement ID. Do you want to add a space in the case, and $ {useestatementNamespaces} is a property in Properties, the default is False.
CacheModelsenable is configured to enable iBATIS's cache model, the default is true.
ValidatesQLMAP is a configuration whether you want to verify the mapping file, the default is false.
3. Providers: Configure the data driver to provide the path and file name of the class profile.
4. Database: Database information, including which database drivers and data connection strings are used.
Connectionstring = "" /> database> 5. Alias: Type alias configuration, in order to use the more convenient use class (shorter name is shorter), you need to make an alias configuration here. 6. TypeHandlers: This is relatively more complicated, and I have not used it at present. Understand from the literal, it is a type of processor, its role is when you use the database that is not supported or unknown in the database (or does not want the default processing method), then take a name for it. And specify the corresponding .NET type to process it. typehandlers> 7. SQLMAPS: The data class mapping file used to contain the currently written and needs to be used. ->
SQLMAPS> The above is the basic content of SQLMap.config. Note that all three ways of supporting Resouce, URL, Embedded are involved in reference external files. Provider.config configuration classes are simple, there are already many different databases of data drivers in the default provoder.config, and the Provider attribute of the Database configured in SQLMAPP.CONFIG is one of the different drivers in the provider.config. . The following is a Add ADO.NET 2.0 Data Access Driver: Name = "SQLServer2.0" Description = "Microsoft SQL Server 7.0 / 2000/2005, Provider V 2.0.0 .0 in framework .net v2.0 " enabled = "true" Default = "True" askEMBLYNAME = "System.data, Version = 2.0.0 .0, culture = neutral, publickeyToken = B 77A 5C 561934E089 "ConnectionClass =" system.data.sqlclient.sqlConnection " Commandclass = "system.data.sqlclient.sqlcommand" ParameterClass = "System.data.sqlclient.sqlparameter" Parameterdbtypeclass = "system.data.sqldbtype" parameterdbtypeproperty = "sqldbtype" DataAdapterclass = "system.data.sqlclient.sqldataadapter" Commandbuilderclass = "system.data.sqlclient.sqlcommandbuilder" UsePositionalParameters = "false" UseParameterprefixinsql = "true" UseParameterPrefixinparameter = "true" Parameterprefix = "@" /> OK, the above is the basic content of SQLMap.config and Provider.config. Let me introduce some of the running log records of the iBatisnet if you use the log4net. This is also a problem I have already spent a lot of time, because the logs are too important, which can record the SQL statement that generates and executes, which is very significant for us to exclude configuration errors. And if you are using the latest version (currently 1.3.0 ), But the document is 1.2.1, it may not be able to come out. according to 1.2.1 After the document introduction, after Web.config (App.config) plus the appropriate configuration section, then copy the log4net.dll and ibatisnet.common.logging.log4net.dll to the bin directory, you may think of the documentation Like, generate a log.txt and record the log. But the fact is not this, and there is also a configuration segment group in the version of 1.3.0:
sectiongroup> The configuration value of the configuration group is as follows: logfactoryadapter> -> logfactoryadapter> logging> ibatis> After the above configuration, the program will be run, and log.txt will create log.txt and log the log. Note: Even after the above configuration is pressed, it is possible to still record the log, which may be a log4net.dll and one or two of the ibatisnet.common.logging.log4net.dll without copying to a bin directory, normal We don't need to quote these two assemblies, just copy them to the running directory, even if you need to record the log, but if you can't find them, the program can still perform normal execution without throwing an exception, if you have no experience Solve this problem Many time. The above is the content you want to introduce today, Hope this Helps. Note: 1. Reference: Data Mapper Guide- 1.2.1 .chm; DataMapper-1.2.1.chm 2. Profile smart prompt: copy the provider.xsd sqlmap.xsd SQLMAPCONFIG.XSD to three files to VS 2005: C: C: / Program Files / Microsoft Visual Studio 8 / XML / Schemas (installation directory) VS 2003: C: / Program Files / Microsoft Visual Studio .NET 2003 / CommON7 / Packages / Schemas / XML (installation directory), you can get the help of IntelliSense when you write the configuration file under the VS IDE, provided the configured file The first node writes the correct namespace and XSD files. 3. Demo download. With VS 2005, you may need to install free versions of SQL 2005.