Mysql-JDBC cannot connect to the Mysql database

Source: Internet
Author: User
Org. mybatis. spring. MyBatisSystemException: nestedexceptionisorg. apache. ibatis. exceptions. PersistenceException: ### Errorqueryingdatabase. Cause: org. springframework. jdbc. restart: nested; nested... mysqljdbc

Org. mybatis. spring. MyBatisSystemException: nested exception is org. apache. ibatis. exceptions. PersistenceException:

Error querying database. cause: org. springframework. jdbc. cannotGetJdbcConnectionException: cocould not get JDBC Connection; nested exception is org. apache. commons. dbcp. SQLNestedException: Cannot load JDBC driver class 'com. mysql. jdbc. driver 'The error may exist in file [D: \ Workspace \ MyGraduationDesign \ target \ classes \ com \ cyq \ bookstore \ mapping \ UsersMapper. xml] The error may involve com. cyq. bookstore. dao. usersDao. selectByPrimaryKeyThe error occurred while executing a queryCause: org. springframework. jdbc. cannotGetJdbcConnectionException: cocould not get JDBC Connection; nested exception is org. apache. commons. dbcp. SQLNestedException: Cannot load JDBC driver class 'com. mysql. jdbc. driver'
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:76)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:399)at com.sun.proxy.$Proxy16.selectOne(Unknown Source)at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:165)at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:69)at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)at com.sun.proxy.$Proxy17.selectByPrimaryKey(Unknown Source)at com.cyq.bookstore.serviceImpl.UsersServiceImpl.getUserById(UsersServiceImpl.java:19)at TestMyBatis.test1(TestMyBatis.java:30)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:85)at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:86)at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:241)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)at org.junit.runners.ParentRunner.run(ParentRunner.java:309)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Caused by: org. apache. ibatis. exceptions. PersistenceException:

Error querying database. cause: org. springframework. jdbc. cannotGetJdbcConnectionException: cocould not get JDBC Connection; nested exception is org. apache. commons. dbcp. SQLNestedException: Cannot load JDBC driver class 'com. mysql. jdbc. driver 'The error may exist in file [D: \ Workspace \ MyGraduationDesign \ target \ classes \ com \ cyq \ bookstore \ mapping \ UsersMapper. xml] The error may involve com. cyq. bookstore. dao. usersDao. selectByPrimaryKeyThe error occurred while executing a queryCause: org. springframework. jdbc. cannotGetJdbcConnectionException: cocould not get JDBC Connection; nested exception is org. apache. commons. dbcp. SQLNestedException: Cannot load JDBC driver class 'com. mysql. jdbc. driver'
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122)at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:73)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:386)... 36 more

Caused by: org. springframework. jdbc. cannotGetJdbcConnectionException: cocould not get JDBC Connection; nested exception is org. apache. commons. dbcp. SQLNestedException: Cannot load JDBC driver class 'com. mysql. jdbc. driver'
At org. springframework. jdbc. datasource. performanceutils. getConnection (performanceutils. java: 80)
At org. mybatis. spring. transaction. SpringManagedTransaction. openConnection (SpringManagedTransaction. java: 82)
At org. mybatis. spring. transaction. SpringManagedTransaction. getConnection (SpringManagedTransaction. java: 68)
At org.apache.ibatis.exe cutor. BaseExecutor. getConnection (BaseExecutor. java: 315)
At org.apache.ibatis.exe cutor. SimpleExecutor. prepareStatement (SimpleExecutor. java: 75)
At org.apache.ibatis.exe cutor. SimpleExecutor. doQuery (SimpleExecutor. java: 61)
At org.apache.ibatis.exe cutor. BaseExecutor. queryFromDatabase (BaseExecutor. java: 303)
At org.apache.ibatis.exe cutor. BaseExecutor. query (BaseExecutor. java: 154)
At org.apache.ibatis.exe cutor. CachingExecutor. query (CachingExecutor. java: 102)
At org.apache.ibatis.exe cutor. CachingExecutor. query (CachingExecutor. java: 82)
At org. apache. ibatis. session. defaults. DefaultSqlSession. selectList (DefaultSqlSession. java: 120)
... 43 more
Caused by: org. apache. commons. dbcp. SQLNestedException: Cannot load JDBC driver class 'com. mysql. jdbc. Driver'
At org. apache. commons. dbcp. BasicDataSource. createConnectionFactory (BasicDataSource. java: 1429)
At org. apache. commons. dbcp. BasicDataSource. createDataSource (BasicDataSource. java: 1371)
At org. apache. commons. dbcp. BasicDataSource. getConnection (BasicDataSource. java: 1044)
At org. springframework. jdbc. datasource. performanceutils. doGetConnection (performanceutils. java: 111)
At org. springframework. jdbc. datasource. performanceutils. getConnection (performanceutils. java: 77)
... 53 more
Caused by: java. lang. ClassNotFoundException: com. mysql. jdbc. Driver

At java.net. URLClassLoader. findClass (Unknown Source)
At java. lang. ClassLoader. loadClass (Unknown Source)
At sun. misc. Launcher $ AppClassLoader. loadClass (Unknown Source)
At java. lang. ClassLoader. loadClass (Unknown Source)
At org. apache. commons. dbcp. BasicDataSource. createConnectionFactory (BasicDataSource. java: 1420)
... 57 more

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.