赞
踩
目录
主要错误就是,找不到我们的 MySql 的驱动类了,所以就会出现以下错误
- Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.cj.jdbc.driver
- at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
- at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
- at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
- at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)
- at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)
- at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:152)
- at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85)
- at com.sun.proxy.$Proxy9.findById(Unknown Source)
- at org.nf.Main.main(Main.java:37)
- Caused by: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.cj.jdbc.driver
- at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.initializeDriver(UnpooledDataSource.java:244)
- at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:223)
- at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:219)
- at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:95)
- at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:432)
- at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:89)
- at org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:139)
- at org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:61)
- at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:337)
- at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:86)
- at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
- at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
- at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
- at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
- at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:89)
- at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
- ... 7 more
-
- Process finished with exit code 1
原来是太粗心了,把 Driver 写成了小写的 driver
改正
因为手写打的太快了,所以就打成了小写的,我们可以发现 idea 还是很智能的,我们改回大写还有提示的
这次是因为大小写的问题报的错,找了好久才发现是写成小写的,顺便就做个笔记,让自己印象深刻一点,下次错了就能够想起来是怎么错的了。还有就是以后要更加细心才行,这些都是很小的失误,但往往就是小失误更加让人头疼。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。