org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class:
### The error may exist in mybatis\role.xml
### The error may involve jdbc.mapper.RoleMapper.countRoles
### The error occurred while executing a query
### Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class:

  在学习最基本的Mybatis配置运行时报出了这样一个错误

(1)一开始的时候看到  Cause: java.sql.SQLException: 当机立断觉得是sql语句写错了,发现确实写错了,反复改了3次,运行仍然报这个错,反复检查了下sql语句,确信没有问题了,很奇怪为什么还是报这个错。

(2)再次看了下报错,后面还有半句话 Error setting driver on UnpooledDataSource.Cause: java.lang.ClassNotFoundException: Cannot find class:  意思是没有成功加载driver驱动。然后是为什么没成功加载,原因是没有找到类,于是去查看了下配置文件

发现了如下的一幕,driver的值居然是空的,崩溃。原因处于此处。

<dataSource type="POOLED">
  <property name="driver" value=""/>
  <property name="url" value="jdbc:mybatis://localhost:3306/ibatis_demo"/>
  <property name="username" value="root"/>
  <property name="password" value="123456"/>
</dataSource>

(3)添加了driver的值,再次运行,又报错【### Error querying database.  Cause: java.sql.SQLException: No suitable driver found for jdbc:mybatis://localhost:3306/ibatis_demo】,又回头查看了下配置文件,发现  jdbc:mybatis 写错,应该为 jdbc:mysql。

再运行,ok。

mybatis 执行查询时报错 【Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: 】的更多相关文章

  1. Mybatis 报错java.sql.SQLException: No suitable driver found for http://www.example.com

    运行项目报错 Error querying database. Cause: java.sql.SQLException: No suitable driver found for http://ww ...

  2. org.springframework.jdbc.UncategorizedSQLException: Error attempting to get column 'alarmGroup' from result set. Cause: java.sql.SQLException: Error

    异常展示: org.springframework.jdbc.UncategorizedSQLException: Error attempting to get column 'alarmGroup ...

  3. java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask

    执行Hive查询: Console是这样报错的 java.sql.SQLException: Error from org.apache.hadoop.hive.ql.exec.mr.MapRedTa ...

  4. CDH5..4.7+phoenix实现查询HBase异常:java.sql.SQLException: ERROR 1102 (XCL02): Cannot get all table regions

    基础环境是用CM 安装的cdh5.4.7,phoenix使用的版本是phoenix-4.5.2-HBase-1.0-bin. 出现异常信息:java.sql.SQLException: ERROR 1 ...

  5. java.sql.SQLException: Error: Error: could not match input

    impala执行sql,输出后我在控制台粘贴执行OK,奇怪了. java.sql.SQLException: Error: Error: could not match input 原因竟然是myba ...

  6. HiveServer2 的jdbc方式创建udf的修改(add jar 最好不要使用),否则会造成异常: java.sql.SQLException: Error while processing statement: null

    自从Hive0.13.0开始,使用HiveServer2 的jdbc方式创建udf的临时函数的方法由: ADD JAR ${HiveUDFJarPath} create TEMPORARY funct ...

  7. presto——java.sql.SQLException: Error executing query与javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?异常问题

    使用presto的时候以mysql为presto的数据源 安装的presto是0.95版本:使用的presto-jdbc是0.202的,这里使用jdbc去访问时候,connection可以链接成功,但 ...

  8. java.sql.SQLException: Error setting driver on UnpooledDataSource.Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for IStudentDaoMapper.Mapperdao.selectcou

    是因为 Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for ...

  9. 无法解析db.properties,spring报错:Caused by: java.sql.SQLException: unkow jdbc driver : ${url}

    db.properties中配置了url等jdbc连接属性: driver=org.sqlite.JDBCurl=jdbc:sqlite:D:/xxx/data/sqliteDB/demo.dbuse ...

随机推荐

  1. CSS定位与布局:普通流

    CSS定位与布局属于CSS的基础,也是CSS布局影响很大的一部分,具体主要包括三种定位与布局机制( Positioning schemes):普通流,浮动,绝对定位. 其实除了这三种之外,还有一些定位 ...

  2. 单堆石子的Nim Game

    两个人轮流捡石子,只有一堆石子,石子数为n.每个人每次至少捡一个石子,至多捡m个.取走最后一个石子的人胜利,若我方先手,求能否胜利. 若n % (m + 1)为0,则必输,否则必赢.

  3. Retrofit 使用flatmap操作符时处理错误、异常

    在实际项目(Retrofit+RxJava框架)中,有时需要先登录,获取token后再去获取用户信息,此时我们使用flatmap操作符比较好. 在RESTResult对象里,包括请求返回的状态:失败还 ...

  4. 【spring cloud】子模块启动报错com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect

    spring cloud子模块启动报错 Caused by: java.lang.ClassNotFoundException: com.netflix.hystrix.contrib.javanic ...

  5. cocos3.x新建项目

    cocos new -p FishRunMan com.game.simple -l cpp

  6. implement-stack-using-queues(easy,但也有思考价值)

    https://leetcode.com/problems/implement-stack-using-queues/ 还有种方法,就是利用同一个队列,知道队列长度前提下,把内容从头到尾,再向尾部依次 ...

  7. HTML5 Canvas 绘制佛教万字

    代码如下: <!DOCTYPE html> <html lang="utf-8"> <meta http-equiv="Content-Ty ...

  8. struts2学习笔记之表单标签的详解:s:checkbox/radio/select/optiontransferselect/doubleselect/combobox

    struts2中的表单标签都是以s标签的方式定义的,同时,struts2为所有标签都提供了一个模板,C:\Users\180172\Desktop\struts2-core-2.2.1.1.jar\t ...

  9. [Android]egit取消文件版本号控制

    开发项目,多人合作开发变得越来越重要了,在此同一时候,使用git作为协同工具也是越来越多.在此.介绍一下egit取消文件版本号控制的方法. (egit即为eclipse中的git插件) 1.打开Nav ...

  10. robotframework使用之元素定位动态ID方法

    转自: http://blog.csdn.net/u011757108/article/details/53418671 一个弹出框所有元素ID竟然的动态的,关闭后再打开,里面的ID又变! 如下图:  ...