I. Problems Emerging
1. As far as I understand it, it probably means that there is no meaning that the table name can not be found.
2. Everything is OK when connecting to a local database or a local area network database (the same database)
3. Error reporting, intercepting the main part
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1f5e6d30] org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'schoolattendance.Snap_record' doesn't exist ### The error may exist in file [E:\pxc\StudentRecordStatisticsWeb\target\classes\core\dao\Snap_recordMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: select id,photo_url,photo_url_face,similarity,match_guid,guid as stu_No, camera_ip,time,device_name,address,create_time,per_type,device_id,device_area from `Snap_record` WHERE match_guid = ? and time >= ? and time <= ? order by time limit ?,? ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'schoolattendance.Snap_record' doesn't exist ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'schoolattendance.Snap_record' doesn't exist at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:234) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
II. My Development Environment
1. First I am jdk1.8+mysql 5.5+spring-boot 2.0.5.RELEASE
2. I used spring-boot + mybatis + ActiveMQ + elastic search in my project.
3. Connected databases are on the extranet (mysql)
3. Analysis of the Reasons for Errors
1. The first thought is that the configuration is not well configured when connecting to the external network database.
2. Reference: https://www.cnblogs.com/ieiang/p/6403818.html After testing, it is true that there is a capitalization in the table name which results in an error.
IV. Solutions
1. Method 1: Change the table name to all lowercase and solve the problem.
2. Method 2: Execute vim/etc/my.cnf and add a line under [mysqld]: lower_case_table_names = 1 (database under linux). Configuration under Windows called my.ini should be the same (not tested under windows).
3. Friendship Tip: mysql database under linux should close the firewall, otherwise it can not be connected.