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 [[email protected]aa]
2018-03-15 01:02:19,681 [http-bio-8080-exec-2] DEBUG [org.springframework.jdbc.support.SQLErrorCodesFactory] - Database product name cached for DataSource [[email protected]aa]: 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,眼花了。
這裡主要是記錄,通過日誌排查錯誤,以及通過執行日誌進行學習。
相關推薦
ssm專案中通過日誌排查錯誤
這裡條件1查詢成功,但是條件2的時候查詢失敗,這裡我們通過日誌排查錯誤。 我直接黏貼我的錯誤日誌 2018-03-15 01:02:19,584 [http-bio-8080-exec-2] DEBUG [com.wwr.dao.CustomerDa
SSM專案中實現Ajax輪詢——定時的通過Ajax查詢服務端
輪詢(polling):客戶端按規定時間定時像服務端傳送ajax請求,伺服器接到請求後馬上返回響應資訊並關閉連線。優點:後端程式編寫比較容易。缺點:請求中有大半是無用,浪費頻寬和伺服器資源。例項:適於小
解決專案中多種日誌框架衝突
問題 最近在開發中,專案使用的日誌框架是log4j,在引入第三方庫tess4j之後,由於tess4j中也使用了日誌,報錯: 原因是:log4j-over-slf4j和slf4j-log4j12是跟Java日誌系統相關的兩個jar包,當它們同時出現在classpath下時,就可能會引
大三筆記(ssm專案中使用layui進行分頁)
本篇文章較為簡單,實現的功能是分頁。下面貼程式碼。 <script src="layui.js" charset="utf-8"></script> <!-- 注意:如果你直接複製所有程式碼到本地,上述js路徑需要改成你本地的 -->
spring專案中 通過自定義applicationContext工具類獲取到applicationContext上下文物件
spring專案在伺服器啟動的時候 spring容器中就已經被建立好了各種物件,在我們需要使用的時候可以進行呼叫. 工具類程式碼如下 import org.springframework.beans.BeansException; import org.springframewo
在SSM專案中使用AOP管理事務的配置教程
今天來記錄一下在SSM專案中經常使用到的事務管理的配置,其實在spring中事務管理有很多方法,但今天我用的是最簡單的這種(還不是因為懶~)aop自動管理事務。 1.首先我們需要有一個整合好的SSM框架專案,具體搭建步驟可以參考我的另一篇文章:最新版的SSM框架spring5.0搭建教程&nb
ssm框架中通過自定義異常實現對事務的管理
什麼時候回滾事務? 在spring的事務管理中我們首先要明白這個問題,一般是在丟擲執行期異常的時候會進行事務的回滾。而spring的宣告式事務管理只接受執行期異常。 異常通常分為執行期異常和編譯期異常。 在java中常見的執行期異常有: NullPointerExcept
SSM專案中使用註解無效
今天在做一個小測試時候出現這樣一現象:在SSM專案中使用註解(@Service、@Autowired、@Component ... )註解均無效!!! 在xml檔案中新增相應配置後測試正常。最初配置資訊如下: 多次除錯沒有效果,jUnit單元測試報錯: 隨後,想到將註解自
SSM專案中引入其他jar找不到,解決辦法(jodconverter-2.2.2.jar)
安裝到mvn裡面 mvn install:install-file -Dfile=jodconverter-2.2.2.jar -DgroupId=org.improve4meaven.jodconverter -DartifactId=jodconverter -Dversion= -
SSM專案中整合WebService
package clack.webserviceimp; import java.net.URL; import java.util.List; import javax.xml.namespace.QName; import javax.xml.ws.Service; import org.apac
ssm專案中的檔案上傳
springmvc中,要想實現上傳檔案需要新增jar包 <dependency> <groupId>commons-fileupload</groupId> <artifa
ssm專案中,springMVC前後端資料互動方法草圖
引言:之前我學jsp、servlet、ssm相關web專案的時候,都接觸到不同的資料互動方式,多種情況像漿糊一樣腦子裡。乾脆我花了一下午的時間總結歸納了所遇到過的情況,在過程中,我查過資料和以前寫過的程式碼,保證每一種情況都是正確存在的。歸納之後,整個人清爽多了。 讀圖須知:每一種情況做了簡單示
spring專案中通過xml配置快取(cache)記錄貼
配置一個spring預設實現的快取(cache)<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:
SSM專案中,使用freemaker加UEditor富文字編輯器
在一個SSM專案中使用到了UEditor富文字編輯器,但是該編輯器使用的是JSP,這個專案不使用JSP,而是使用了freemaker,查找了一些資料對UEditor進行更改。 首先是替換掉UEditor使用的controller.jsp,把該檔案重新命名為ol
獲取SSM專案中所有的URL
1、在springmvc配置加上兩個bean: <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
maven新建ssm專案中pom.xml檔案內容
1、開發工具使用時的idea <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi
react專案中通過 iscroll 實現上拉載入,下拉重新整理
基於 iscroll 實現的 react 元件 第一步:引入外掛 npm install reactjs-iscroll --save 可在專案下的package.json檔案內dependencies下看到安裝好的外掛版本; 第二步:在專案中使用 import iS
ssm專案整合log4j日誌
在專案classpath下建立一個log4j.properties檔案: ################################################################################ #①配置根Logge
SSM專案中存入資料庫中文亂碼的問題
存入資料庫中文亂碼的問題 ① 連線資料庫的配置語句 SSM框架中使用C3P0連線資料庫語句 jdbc:mysql://localhost:3306/dbname 改為 jdbc:mysql://localhost:3306/dbname
專案中log日誌檔案的生成和管理
每個應用程式一般都會生成自己的log日誌檔案,用來記錄使用過程中的一些關鍵操作和訊息記錄、響應等,同時方便問題的追蹤定位,下邊來介紹實戰專案中到底如何生成管理專案日誌: 首先註冊訊息 qInstallMessageHandler(QtMessageOutput);