<> Exception generation environment
use Mybatis Plus frame An exception was generated during
<> Exception description
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Unknown
column 'name' in 'field list' ### The error may exist in
cn/bloghut/mapper/UserMapper.java (best guess) ### The error may involve
defaultParameterMap ### The error occurred while setting parameters ### SQL:
SELECT id,name,email,age FROM user WHERE id=? ### Cause:
java.sql.SQLSyntaxErrorException: Unknown column 'name' in 'field list' ; bad
SQL grammar[]; nested exception is java.sql.SQLSyntaxErrorException: Unknown
column'name' in 'field list' at
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(
SQLErrorCodeSQLExceptionTranslator.java:235) at
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate
(AbstractFallbackSQLExceptionTranslator.java:72) at
org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(
MyBatisExceptionTranslator.java:74) at org.mybatis.spring.SqlSessionTemplate
$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440) at com.sun.proxy.
$Proxy14.selectOne(Unknown Source) at
org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:159) at
com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(
MybatisMapperMethod.java:89) at
com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(
MybatisMapperProxy.java:61) at com.sun.proxy.$Proxy18.selectById(Unknown Source)
at cn.bloghut.test.TestApp.main(TestApp.java:19) Caused by:
java.sql.SQLSyntaxErrorException: Unknown column'name' in 'field list'
<> Cause of abnormality
main cause : The field name of the data table is different from the attribute name of the entity class
Secondary cause : Due to my carelessness , Wrong database connection .
I have two local databases. One is mybatis One is mybatisplus,mybatis There is one in the database user surface ,mybatisplus The database also has one user surface , however mybatis Database user The table field name is inconsistent with the entity class attribute name in my current exercise , That's why the exception occurs
I wanted to connect mybatisplus Database , Careless mistake , Then there was a problem .
The console error is obvious , Caused by name mismatch
<> terms of settlement
Change the table name of the connection to
Normal execution
Technology