ssm项目中通过日志排查错误

这里写图片描述
这里条件1查询成功,但是条件2的时候查询失败,这里我们通过日志排查错误。
我直接黏贴我的错误日志

2018-03-15 01:02:19,584 [http-bio-8080-exec-2] DEBUG [com.wwr.dao.CustomerDao.find] - ==>  Preparing: select * from t_customer WHERE khno like ? name like ? limit ?,? 
  2018-03-15 01:02:19,589 [http-bio-8080-exec-2] DEBUG [com.wwr.dao.CustomerDao.find] - ==> Parameters: %213%(String), %22%(String), 0(Integer), 10(Integer)
  2018-03-15 01:02:19,623 [http-bio-8080-exec-2] DEBUG [org.springframework.core.env.StandardEnvironment] - Adding [systemProperties] PropertySource with lowest search precedence
  2018-03-15 01:02:19,623 [http-bio-8080-exec-2] DEBUG [org.springframework.core.env.StandardEnvironment] - Adding [systemEnvironment] PropertySource with lowest search precedence
  2018-03-15 01:02:19,623 [http-bio-8080-exec-2] DEBUG [org.springframework.core.env.StandardEnvironment] - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
  2018-03-15 01:02:19,624 [http-bio-8080-exec-2] INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
  2018-03-15 01:02:19,625 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.xml.DefaultDocumentLoader] - Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]
  2018-03-15 01:02:19,627 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.xml.BeansDtdResolver] - Found beans DTD [http://www.springframework.org/dtd/spring-beans-2.0.dtd] in classpath: spring-beans-2.0.dtd
  2018-03-15 01:02:19,635 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader] - Loading bean definitions
  2018-03-15 01:02:19,646 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating shared instance of singleton bean 'DB2'
  2018-03-15 01:02:19,646 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'DB2'
  2018-03-15 01:02:19,646 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Eagerly caching bean 'DB2' to allow for resolving potential circular references
  2018-03-15 01:02:19,671 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Finished creating instance of bean 'DB2'
  2018-03-15 01:02:19,671 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating shared instance of singleton bean 'Derby'
  2018-03-15 01:02:19,671 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'Derby'
  2018-03-15 01:02:19,671 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Eagerly caching bean 'Derby' to allow for resolving potential circular references
  2018-03-15 01:02:19,672 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Finished creating instance of bean 'Derby'
  2018-03-15 01:02:19,672 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating shared instance of singleton bean 'H2'
  2018-03-15 01:02:19,672 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'H2'
  2018-03-15 01:02:19,672 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Eagerly caching bean 'H2' to allow for resolving potential circular references
  2018-03-15 01:02:19,673 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Finished creating instance of bean 'H2'
  2018-03-15 01:02:19,673 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating shared instance of singleton bean 'HSQL'
  2018-03-15 01:02:19,673 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'HSQL'
  2018-03-15 01:02:19,673 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Eagerly caching bean 'HSQL' to allow for resolving potential circular references
  2018-03-15 01:02:19,673 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Finished creating instance of bean 'HSQL'
  2018-03-15 01:02:19,673 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating shared instance of singleton bean 'Informix'
  2018-03-15 01:02:19,673 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'Informix'
  2018-03-15 01:02:19,673 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Eagerly caching bean 'Informix' to allow for resolving potential circular references
  2018-03-15 01:02:19,673 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Finished creating instance of bean 'Informix'
  2018-03-15 01:02:19,674 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating shared instance of singleton bean 'MS-SQL'
  2018-03-15 01:02:19,674 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'MS-SQL'
  2018-03-15 01:02:19,674 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Eagerly caching bean 'MS-SQL' to allow for resolving potential circular references
  2018-03-15 01:02:19,674 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Finished creating instance of bean 'MS-SQL'
  2018-03-15 01:02:19,674 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating shared instance of singleton bean 'MySQL'
  2018-03-15 01:02:19,674 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'MySQL'
  2018-03-15 01:02:19,674 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Eagerly caching bean 'MySQL' to allow for resolving potential circular references
  2018-03-15 01:02:19,675 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Finished creating instance of bean 'MySQL'
  2018-03-15 01:02:19,675 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating shared instance of singleton bean 'Oracle'
  2018-03-15 01:02:19,675 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'Oracle'
  2018-03-15 01:02:19,675 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Eagerly caching bean 'Oracle' to allow for resolving potential circular references
  2018-03-15 01:02:19,676 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Finished creating instance of bean 'Oracle'
  2018-03-15 01:02:19,676 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating shared instance of singleton bean 'PostgreSQL'
  2018-03-15 01:02:19,676 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'PostgreSQL'
  2018-03-15 01:02:19,676 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Eagerly caching bean 'PostgreSQL' to allow for resolving potential circular references
  2018-03-15 01:02:19,676 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Finished creating instance of bean 'PostgreSQL'
  2018-03-15 01:02:19,676 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating shared instance of singleton bean 'Sybase'
  2018-03-15 01:02:19,676 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'Sybase'
  2018-03-15 01:02:19,676 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Eagerly caching bean 'Sybase' to allow for resolving potential circular references
  2018-03-15 01:02:19,677 [http-bio-8080-exec-2] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Finished creating instance of bean 'Sybase'
  2018-03-15 01:02:19,677 [http-bio-8080-exec-2] INFO  [org.springframework.jdbc.support.SQLErrorCodesFactory] - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
  2018-03-15 01:02:19,677 [http-bio-8080-exec-2] DEBUG [org.springframework.jdbc.support.SQLErrorCodesFactory] - Looking up default SQLErrorCodes for DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@ccdcaa]
  2018-03-15 01:02:19,681 [http-bio-8080-exec-2] DEBUG [org.springframework.jdbc.support.SQLErrorCodesFactory] - Database product name cached for DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@ccdcaa]: name is 'MySQL'
  2018-03-15 01:02:19,682 [http-bio-8080-exec-2] DEBUG [org.springframework.jdbc.support.SQLErrorCodesFactory] - SQL error codes for 'MySQL' found
  2018-03-15 01:02:19,682 [http-bio-8080-exec-2] DEBUG [org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator] - Translating SQLException with SQL state '42000', error code '1064', message [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 'name like '%22%' 

            limit 0,10' at line 5]; SQL was [] for task [
### Error querying database.  Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 'name like '%22%' 

            limit 0,10' at line 5
### The error may exist in file [D:\work\Tomcat\apache-tomcat-7.0.32\webapps\CRMStudy\WEB-INF\classes\com\wwr\mappers\customerMapper.xml]
### The error may involve com.wwr.dao.CustomerDao.find-Inline
### The error occurred while setting parameters
### SQL: select * from t_customer    WHERE khno like ?              name like ?         limit ?,?
### Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 'name like '%22%' 

            limit 0,10' at line 5
]

这里,mybatis开始准备sql语句是不是就看着不对劲,继续看下去,接下来是spring为我们匹配数据库,匹配结果是mysql,然后接下来日志中,会告诉你:

The error may exist in file [D:\work\Tomcat\apache-tomcat-7.0.32\webapps\CRMStudy\WEB-INF\classes\com\wwr\mappers\customerMapper.xml]

错误可能发生在customerMapper.xml中

The error may involve com.wwr.dao.CustomerDao.find-Inline

错误可能发生在dao的find方法调用中

### The error occurred while setting parameters
### SQL: select * from t_customer    WHERE khno like ?              name like ?         limit ?,?

错误发生在当插入参数的过程中
好了,错误排查,原因原来是少了and,眼花了。
这里主要是记录,通过日志排查错误,以及通过运行日志进行学习。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值