mapper接口方式的开发整合,数据库连接不上,知道的大佬告我一下

解决方案 »

  1.   

    是username你注意你的名字
      

  2.   

    org.apache.commons.dbcp2.BasicDataSource 这个是哪个包里的? 我记得不是这个么org.apache.commons.dbcp.BasicDataSource, 升级了?
      

  3.   

    HTTP Status 500 - nested exception is org.apache.ibatis.exceptions.PersistenceException:type Exception reportmessage nested exception is org.apache.ibatis.exceptions.PersistenceException:description The server encountered an internal error that prevented it from fulfilling this request.exceptionorg.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: Cannot create PoolableConnectionFactory (Communications link failureLast packet sent to the server was 0 ms ago.)
    ### The error may exist in com/itheima/mappers/Usermapper.xml
    ### The error may involve com.itheima.mappers.Usermapper.findUser
    ### The error occurred while executing a query
    ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failureLast packet sent to the server was 0 ms ago.)
    org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
    org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
    com.sun.proxy.$Proxy14.selectOne(Unknown Source)
    org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)
    org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82)
    org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
    com.sun.proxy.$Proxy15.findUser(Unknown Source)
    servlet.yz.doPost(yz.java:37)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    root causeorg.apache.ibatis.exceptions.PersistenceException: 
    ### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory 没办法发图片,我就复制了
      

  4.   

    HTTP Status 500 - nested exception is org.apache.ibatis.exceptions.PersistenceException:type Exception reportmessage nested exception is org.apache.ibatis.exceptions.PersistenceException:description The server encountered an internal error that prevented it from fulfilling this request.exceptionorg.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: Cannot create PoolableConnectionFactory (Communications link failureLast packet sent to the server was 0 ms ago.)
    ### The error may exist in com/itheima/mappers/Usermapper.xml
    ### The error may involve com.itheima.mappers.Usermapper.findUser
    ### The error occurred while executing a query
    ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failureLast packet sent to the server was 0 ms ago.)
    org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
    org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
    com.sun.proxy.$Proxy14.selectOne(Unknown Source)
    org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)
    org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82)
    org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
    com.sun.proxy.$Proxy15.findUser(Unknown Source)
    servlet.yz.doPost(yz.java:37)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    root causeorg.apache.ibatis.exceptions.PersistenceException: 
    ### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory 
      

  5.   

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> 试试
      

  6.   

    配置文件中,url里的 & 符号你换成&amp; 试试
    jdbc:mysql://localhost:3306/sport?useUnicode=true&amp;characterEncoding=utf8&amp;autoReconnect=true
      

  7.   

    destory-method is not allowed to appear in element bean
      

  8.   

    根据10楼将bean后面加了destory-method结果报错说不允许出现,然后删了之后好了,真是不解
      

  9.   

    我加了destory-method出现叉号删除以后居然连接成功了,好奇怪