在项目开发中遇到这样的问题
这是一个程序批量向数据库插入 一些用户
数据库是mysql
底层用的是数据库连接池 其中 datasource如下图所示
结果是 出现如下异常
()org.springframework.dao.DataAccessResourceFailureException: SqlMapClient operation; SQL [];
--- The error occurred in ibatis/secondary/sqlmap/task_otherthread.xml.
--- The error occurred while applying a parameter map.
--- Check the TaskOtherThreadDao.insertWoman-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 5,007 milliseconds ago. The last packet sent successfully to the server was 5,006 milliseconds ago.; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in ibatis/secondary/sqlmap/task_otherthread.xml.
--- The error occurred while applying a parameter map.
--- Check the TaskOtherThreadDao.insertWoman-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 5,007 milliseconds ago. The last packet sent successfully to the server was 5,006 milliseconds ago.
结果是数据库中已经插入了1些数据
我有两个疑问
疑问1:在出异常之前,这个插入操作是一直拿着 数据库连接池中的同一个链接吗?
疑问2: 就是怎么会出现以上这个链接失败的异常
1:不是;
2:你看你的配置最大等待时间是1S,报错是链接失败,也告诉你,5s了没有接收服务端的消息,ibatis就会报这个错误,你检查下网络,我看你user都没设置属性,是有null的,不报错才怪呢!
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。