1. 程式人生 > >將web應用和mysql都部署到linux下,web應用通過jdbc就無法獲取到mysql連線。

將web應用和mysql都部署到linux下,web應用通過jdbc就無法獲取到mysql連線。

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 [C:\Users\kingzhao\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\netShop\WEB-INF\classes\mapper\CategroyDao.xml]
### The error may involve team.hymxj.dao.CategoryDao.findAllCategory
### 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.doGet(FrameworkServlet.java:861)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:742)
	org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:712)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:119)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	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)

問題發現:原來,在Linux下,預設安裝的mysql,是大小寫敏感的,比如資料庫名字,表名的大小寫都必須與資料庫的一致,windows下的mysql預設情況都能識別。

要想讓linux下的mysql中的表名能大小寫通用,那麼需要相關設定。

修改/etc/my.cnf


在[mysqld]下加入一行:lower_case_table_names=1


這樣,表名就可以不大小寫敏感,但資料庫名還得大小寫正確輸入哦。