nested exception is org.apache.ibatis.exceptions.PersistenceException

本文解决了一个关于SSM框架初级项目中出现的数据库连接失败问题。错误原因为配置文件中数据库URL设置不正确,缺少必要的“jdbc:mysql://”前缀。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SSM初级项目运行报错

Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
org.springframework.web.util.NestedServletException: 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: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
### The error may exist in file [F:\StudyMath\sm_web\target\sm_web\WEB-INF\classes\mapper\SMUserLogin.xml]
### The error may involve com.sm.dao.SMUserLoginDao.sm_userlogin
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

我的applicatoinContext.xml的配置是:


一直看不出来原因,后面仔细看了下是jdbcUrl的value的错误。少了一段头:

<property name="jdbcUrl" value="sql.w300.vhostgo.com/lanxiaofang?rewriteBatchedStatements=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false&amp;autoReconnect=true"></property>
        

要改成:

<property name="jdbcUrl" value="jdbc:mysql://sql.w300.vhostgo.com/lanxiaofang?rewriteBatchedStatements=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false&amp;autoReconnect=true"></property>
        

分析一下组成:

<property name="jdbcUrl" value="jdbc:mysql://数据库连接的主机名或IP地址/数据库连接名?rewriteBatchedStatements=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false&amp;autoReconnect=true"></property>
        

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

懒笑翻

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值