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&useUnicode=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true"></property>
要改成:
<property name="jdbcUrl" value="jdbc:mysql://sql.w300.vhostgo.com/lanxiaofang?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true"></property>
分析一下组成:
<property name="jdbcUrl" value="jdbc:mysql://数据库连接的主机名或IP地址/数据库连接名?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true"></property>