As I recently conducted a cross-database operation test, I started IBatisNet IBatis. dataMapper.1.6.2/IBatis. dataAccess.1.9.2) + SQL Server2005 was used smoothly, but some problems occurred when IBatisNet + MySQL5.1 was used. After hard work and online collection, I finally solved the problem and solution. I will share them one by one.
Problem description:
1. the error message is "Check the MySQL.
If this problem occurs, download mySQL-connector-net. If you have downloaded and installed it, continue to check the providers of IBatisNet. whether the enabled of the MySQL provider node in the config file is set to "true". If it is set to "true", continue to check the provider, some official configurations use the dynamic link library file version which is very old. You need to modify it manually, for example:
Before modification:
- <provider
-
- name="MySQL"
-
- description="MySQL, MySQL provider 1.0.7.30072"
-
- enabled="false"
-
- assemblyName="MySQL.Data,
- Version=1.0.7.30072, Culture=neutral,
- PublicKeyToken=c5687fc88969c44d" connectionClass="MySQL.Data.MySQLClient.MySQLConnection"
-
- commandClass="MySQL.Data.MySQLClient.MySQLCommand"
-
- parameterClass="MySQL.Data.MySQLClient.MySQLParameter"
-
- parameterDbTypeClass="MySQL.Data.MySQLClient.MySQLDbType"
-
- parameterDbTypeProperty="MySQLDbType"
-
- dataAdapterClass="MySQL.Data.MySQLClient.MySQLDataAdapter"
-
- commandBuilderClass="MySQL.Data.MySQLClient.MySQLCommandBuilder"
-
- usePositionalParameters="false"
-
- useParameterPrefixInSQL="true"
-
- useParameterPrefixInParameter="true"
-
- parameterPrefix="?"
-
- allowMARS="false"
-
- />
-
After modification (please note that, if it is set to false, the database cannot be connected successfully ):
- <provider
-
- name="MySQL"
-
- description="MySQL,
- MySQL provider V6.3.2.0"
-
- enabled="true"
-
- assemblyName="MySQL.Data, Version=6.3.2.0,
- Culture=neutral, PublicKeyToken=c5687fc88969c44d"
- connectionClass=
- "MySQL.Data.MySQLClient.MySQLConnection"
-
- commandClass=
- "MySQL.Data.MySQLClient.MySQLCommand"
-
- parameterClass=
- "MySQL.Data.MySQLClient.MySQLParameter"
-
- parameterDbTypeClass=
- "MySQL.Data.MySQLClient.MySQLDbType"
-
- parameterDbTypeProperty=
- "MySQLDbType"
-
- dataAdapterClass=
- "MySQL.Data.MySQLClient.MySQLDataAdapter"
-
- commandBuilderClass=
- "MySQL.Data.MySQLClient.MySQLCommandBuilder"
-
- usePositionalParameters="false"
-
- useParameterPrefixInSQL="true"
-
- useParameterPrefixInParameter="true"
-
- parameterPrefix="?"
-
- allowMARS="false"
-
- />
-
2. The error message "Unable to open connection to" MySQL, MySQL provider V6.3.2.0 "is displayed ".
This error may be caused by a problem with the link string of the configuration file specified by the Configure method. Here is my link, which is for your reference only.
- <? Xml version = "1.0" encoding = "UTF-8"?>
-
- <SQLMapConfig xmlns =
- "Http://ibatis.apache.org/dataMapper" xmlns: xsi =
- Http://www.w3.org/2001/XMLSchema-instance>
-
- <! -- The above is a fixed format. From here, the following are user configuration items -->
-
- <Settings>
-
- <! -- This option indicates whether to use the cache. The default value is true. -->
-
- <Setting cacheModelsEnabled = "true"/>
-
- <! -- When this option is true,
- When you call the specified ing, you must always provide the complete name, for example:
- QueryForObject ("Namespace. statement. Id ");
- -->
-
- <Setting useStatementNamespaces = "false"/>
-
- </Settings>
-
- <! -- Data Driver provides the path and file name of the class configuration file -->
-
- <Providers resource = "providers. config"/>
-
- <! -- Specify an Attribute source, which is equivalent to setting some attribute variables,
- For this file, see the following -->
-
- <! -- Specify the data source $ {datasource }$ {database}
- $ {Userid }$ {password}
- Value defined for DataBase. config -->
-
- <Database>
-
- <! -- <Provider name = "ByteFx"> </provider>
-
- <DataSource name = "IBatisNet"
- ConnectionString = "Database = zy_test; Data Source =
- Localhost; User Id = root; Password = 1234 "/> -->
-
- <Provider name = "MySQL"> </provider>
-
- <DataSource name = "IBatisNet"
- ConnectionString = "Host = localhost; UserName =
- Root; Password = 1234; Database = zy_test; Port = 3306;
- CharSet = utf8; Allow Zero Datetime = true "/>
-
- </Database>
-
- <! -- Specify the location of the mapped file -->
-
- <SQLMaps>
-
- <! -- From the Assembly
-
- <SQLMap embedded = "$ {root} Person. xml, $ {assembly}"/> -->
-
- <! -- From file -->
-
- <SQLMap resource = "SQLDetailXml/SystemXml/RoleInfo. xml"/>
-
- <SQLMap resource = "SQLDetailXml/SystemXml/ModuleInfo. xml"/>
-
- <SQLMap resource = "SQLDetailXml/SystemXml/UserInfo. xml"/>
-
- </SQLMaps>
-
- </SQLMapConfig>
-
3. The error message "Character set 'gbk' is not supported" is displayed.
If this problem occurs, you may have used the MySQL-connector-net version, because the character encoding provided in MySQL Connector 1.07 is limited and the web cannot be found. the encoding type set in config. If there is no gbk, change to MySQL Connector of a later version.