1. 程式人生 > 其它 >MyBatis報錯:Cannot determine value type from string....

MyBatis報錯:Cannot determine value type from string....

報錯資訊:

org. springframework. web. util. NestedServletExcepti on:Request processing f ailed; 
nested exception is org.springframework. dao. DataIntegrityViolationExceptionError attempting to Cannot determine. value tvpe from string ” 2019-9-25 05:11: 48’nested ex ception is :java. sql. SQLDat aException: Cannot determine value tvpe from string ’2019-9-25 05: 11: 48

新建查詢後出現了這個錯誤,經發現是實體類接收資料庫資料型別不匹配導致的。(欄位和屬性沒有對上

日期格式在經過DATE_FORMAT之後

DATE_FORMAT(update_time,'%Y-%c-%d %h:%i:%s') as 'update_time',

使用Date型別屬性接收報錯,修改後使用String型別的屬性接收。

還有一種情況也會導致報這種錯:

還有一種情況,建構函式問題,有參構造建立後,無參構造沒有建立,也會導致這個問題。弄了一下午,換資料庫、換欄位、換屬性名都沒解決,最後想起來是不是缺少無參構造了

There was an unexpected error (type=Internal Server Error, status=500).
Error attempting to get column 'u_account' from result set. 
Cause: java.sql.SQLDataException: Cannot determine value type from string '201577D0510' ;
Cannot determine value type from string '201577D0510'; nested exception is java.sql.SQLDataException:
Cannot determine value type from string '201577D0510' org.springframework.dao.DataIntegrityViolationException: Error attempting to get column 'u_account' from result set.
Cause: java.sql.SQLDataException: Cannot determine value type from string '201577D0510' ;
Cannot determine value type from string '201577D0510';
nested exception is java.sql.SQLDataException: Cannot determine value type from string '201577D0510' at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:84) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) at com.sun.proxy.$Proxy65.selectList(Unknown Source)