记录一个关于mybatis xml批量更新的问题: 2020-04-05

数据库url:jdbc:mysql://localhost:3306/test_lib_dev?serverTimezone=Asia/Shanghai

mybatis xml批量更新配置:

String[] adminAccounts = new String[] {"20204058631b264"};
Integer delTAdminInfo = mapper.delTAdminInfo(adminAccounts);
 Integer delTAdminInfo(String[] list);
Integer delTAdminInfo = mapper.delTAdminInfo("20204058631b264");
 Integer delTAdminInfo(String... list);


        
            update t_admin_info 
              
                  
                       admin_name = #{item.adminName,jdbcType=VARCHAR},
                  
                  
                        pwd = #{item.pwd,jdbcType=VARCHAR},
                  
                  
                       gender = #{item.gender,jdbcType=VARCHAR},
                  
                  
                       age = #{item.age,jdbcType=INTEGER},
                  
                  
                       id_num = #{item.idNum,jdbcType=VARCHAR},
                  
                  
                       tel_num = #{item.telNum,jdbcType=VARCHAR},
                  
                  
                       mobile_phone = #{item.mobilePhone,jdbcType=VARCHAR},
                  
                  
                       email = #{item.email,jdbcType=VARCHAR},
                  
                  
                       image = #{item.image,jdbcType=VARCHAR},
                  
                  
                       birth_date = #{item.birthDate,jdbcType=DATE},
                  
                  
                       address = #{item.address,jdbcType=DATE},
                  
                  
                       role_id = #{item.roleId,jdbcType=INTEGER},
                  
                  
                       library_code = #{item.libraryCode,jdbcType=VARCHAR},
                  
                  
                       library_name = #{item.libraryName,jdbcType=VARCHAR},
                  
                  
                       status = #{item.status,jdbcType=TINYINT},
                  
                  
                       hobby = #{item.hobby,jdbcType=VARCHAR},
                  
                  
                       updated_by = #{item.updatedBy,jdbcType=VARCHAR},
                  
                       updated_dt = now(),
              
                  where 
                       admin_account = #{item.adminAccount,jdbcType=VARCHAR}
        
     
### 提示如下错误:
  org.apache.ibatis.logging.jdbc.BaseJdbcLogger DEBUG  ==>  Preparing: update t_admin_info SET admin_name = ?, updated_dt = now() where admin_account = ? ; update t_admin_info SET admin_name = ?, updated_dt = now() where admin_account = ?  
org.apache.ibatis.logging.jdbc.BaseJdbcLogger DEBUG  ==> Parameters: 开发3(String), 20204058631b263(String), 开发4(String), 20204058631b264(String) 
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'update t_admin_info 
               SET admin_name = '开发4',
                  
' at line 24
修改数据库url:
数据库url:jdbc:mysql://localhost:3306/test_lib_dev?allowMultiQueries=true&serverTimezone=Asia/Shanghai

又提示:
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error building SqlSession.
### Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 114; 对实体 "serverTimezone" 的引用必须以 ';' 分隔符结尾。
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:80)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:64)
    at com.zj.test.TestUpdate.main(TestUpdate.java:25)
最后将数据库url:jdbc:mysql://localhost:3306/test_lib_dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
问题解决,记录一哈!

你可能感兴趣的:(记录一个关于mybatis xml批量更新的问题: 2020-04-05)