Problem description and solution

1,java.lang.ExceptionInInitializerError....The error may exist in
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL
Mapper Configuration. Cause: java.io.IOException: Could not find resource

  Solution :

2, Dynamic query foreach report errors :

  Solution :

3, Run first Mybatis Project reporting error :

Solution :

1) The main reason is that there is a problem with the coding method , The coding methods of documents and projects are changed to UTF-8 that will do

2) probably xml There are Chinese comments in the configuration file , Chinese notes can be deleted or xml The coding method is determined by UTF-8 Change to UTF8, The problem is over

  4, The variable property name is inconsistent with the field name of the database, resulting in the following error :

  Solution :

5, When all configurations are OK , The query database is empty , First of all, you can be sure that the configuration is OK , There is no problem with the database connection , Then there may be a problem with data reading :

Solution : Or is the variable attribute name inconsistent with the field name of the database ( All for null, That means you didn't match any of them , halo ~), Therefore, it is important to develop a good programming habit , There are three possible solutions

1) De entity class modification set method ,Mybatis Yes set Method , So you just need to modify it set Method can be queried ( Not recommended )

2) Alias database field names ( It is recommended when there are few fields )
<select id="queryById" resultType="user"> select userid as id, username as
name, password from mybatis.user where userid = #{id} </select>
3) Result set mapping ResultMap( Recommended use )
<resultMap id="allUser" type="user"> <!--column Fields in the database ,property Properties in entity classes -->
<result column="username" property="name"/> <result column="userid"
property="id"/> </resultMap> <select id="getAllUserList" resultMap="allUser">
select * from mybatis.user; </select>
### Error querying database.  Cause:
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
### The error may exist in com/dao/UserMapper.xml
### The error may involve com.dao.UserMapper.getUerList
### The error occurred while executing a query
### Cause: java.sql.SQLNonTransientConnectionException: Public Key Retrieval
is not allowed 

  Solution :useSSL An insecure connection was established , The system does not allow public key retrieval

### Error querying database.  Cause:
org.apache.ibatis.reflection.ReflectionException: Error instantiating class
com.pojo.Employees with invalid types
(int,String,String,String,String,String,Double,Double,int,int,Date) or values
(100,Steven,K_ing,SKING,515.123.4567,AD_PRES,24000.0,null,null,90,Fri Apr 03
00:00:00 SGT 1992). Cause: java.lang.IllegalArgumentException

Solution : After confirming that there is no problem with the configuration , An illegal parameter exception occurred
. The problem is that the specific instance cannot be initialized , By consulting relevant materials , hear mybatis When initializing an object , Properties need to be loaded with a parameterless constructor , Therefore, it is normal to add a parameterless construction method to the entity class .

8,Error updating database.  Cause:
java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '9' for key

Solution : id by 9 Duplicate primary key , It is possible that the same insert operation was performed twice , modify id that will do

9, Invalid binding state

  Solution : in use <package name=" Package name "/> perhaps <mapper
class=" Interface name "/> Time , The mapping file name must be the same as the interface name , If not, an error will be reported . use <mapper resource=""/> Time , The same name cannot be wrong .


<> If you encounter errors later, you will continue to update the blog .....

©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage Python Study notes ( one )evo Tool usage problems ——Degenerate covariance rank, Umeyama alignment is not possibleRISC-V_GD32VF103-TIMER0 timer interrupt java Array subscript variable _Java Basic grammar : array be based on stm32 Control four-wheel trolley motor drive ( one ) be based on redis Design of liking function Software engineering career planning mysql Query random data by conditions _MySQL Random query of several qualified records centos7 install RabbitMq