mybatis使用连接失败
来源:3-1 集成持久层框架Mybatis

weixin_慕丝4388768
2021-03-15
05.443 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet]:175 Servlet.service() for servlet [dispatcherServlet] in context with path [/system] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
The error may exist in file [D:\learning\Spring MOOC\course\system\target\classes\mapper\TestMapper.xml]
The error may involve com.course.system.mapper.TestMapper.list
The error occurred while executing a query
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.] with root cause
写回答
2回答
-
weixin_慕丝4388768
提问者
2021-03-16
找到问题了,在application.properties里面的配置,username错了,反正如果没连接上,大家多找找代码有啥不一样吧...
00 -
甲蛙
2021-03-16
连不上数据库,就看地址、用户名、密码是否正确。
先像课程一样,在idea的database里把数据库连接配置好,连接成功再写到代码里
00
相似问题