很长时间没写后台代码有点生疏了,这不今天又出点小插曲,写个文章记录下。

由于要上传点数据到后台,顺手整了个mybatis+springmvc。在保存数据时出现了异常。

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@71670c91] was not registered for synchronization because synchronization is not active
JDBC Connection [jdbc:mysql://localhost:3306/statsdb?useUnicode=true&characterEncoding=UTF-8, UserName=root@localhost, MySQL Connector Java] will not be managed by Spring
==> Preparing: insert into record_info
==> Parameters:
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@71670c91]

看提示还以为事务啥的有问题,一通资料查找处理后,发现问题还在。

于是换postman调试接口,看看具体什么错误

BadSqlGrammarException

有点懵逼,SQL都是generator生成的。抱着怀疑的态度,xml中的SQL改的简单点 insert into record_info (model) values ('xx'),运行居然成功。果然是这块有问题,于是继续改SQL,改成参数形式:insert into record_info (model) VALUES (#{model,jdbcType=VARCHAR}),运行成功发现没值。这时感觉有点不对,值肯定传了啊。于是查看赋值代码,这一看发现问题了,忘了提取data数据进行转换,改正后还原xml代码,运行成功...

if (!StringUtils.isBlank(body)) {
       //错误的写法
       //RecordInfo recordInfo = getGson().fromJson(body, RecordInfo.class);        //改正后写法
JsonParser jsonParser = new JsonParser();
JsonElement ele = jsonParser.parse(body);
JsonElement jo = ele.getAsJsonObject().get("data");
RecordInfo recordInfo = getGson().fromJson(jo, RecordInfo.class);
if (recordInfo != null) {
reportService.addPosRecordInfo(recordInfo);
}
}

  

结论:由于参数赋值有问题,导致SQL运行出错

Mybatis异常处理之MySQL Connector Java] will not be managed by Spring的更多相关文章

  1. mybatis/callablestatement调用存储过程mysql connector产生不必要的元数据查询

    INFO | jvm 1 | 2016/08/25 15:17:01 | 16-08-25 15:17:01 DEBUG pool-1-thread-371dao.ITaskDao.callProce ...

  2. MySQL Connector/J 6.x jdbc.properties 配置, mysql-connector-java-6.0.4.jar 异常

    今天学习SSM框架整合,完成Spring和mybatis这两大框架的整合做测试时候出来很多问题,主要来自于配置文件. 我这里重点说一下Mysql数据驱动配置. 配置pom.xml时候去网站 MySQL ...

  3. MySQL Connector/J

    5.1 Developer Guide 1. MysQL为由Java语言编程的客户端程序提供连接:MySQL Connector/J,这是一个实现Java Database Connectivity( ...

  4. [转]MySQL Connector/C++(一)

    http://www.cnblogs.com/dvwei/archive/2013/04/18/3029464.html#undefined#undefined MySQL Connector/C++ ...

  5. Spring学习总结(五)——Spring整合MyBatis(Maven+MySQL)二

    接着上一篇博客<Spring整合MyBatis(Maven+MySQL)一>继续. Spring的开放性和扩张性在J2EE应用领域得到了充分的证明,与其他优秀框架无缝的集成是Spring最 ...

  6. Spring学习总结(五)——Spring整合MyBatis(Maven+MySQL)一

    MyBatis-Spring 会帮助你将 MyBatis 代码无缝地整合到 Spring 中. 使用这个类库中的类, Spring 将会加载必要的MyBatis工厂类和 session 类. 这个类库 ...

  7. MySQL connector c++使用笔记

    MySQL的connector官方地址: http://dev.mysql.com/downloads/connector/ 针对c++来说, 可以选择c或者c++的库. c++的实现是参考了java ...

  8. presto 配置mysql.properties异常Database (catalog) must not be specified in JDBC URL for MySQL connector

    在presto 0.210 以后配置mysql.properties的时候,对于jdbc-url属性配置后面要加上对应要链接的database connection-url=jdbc:mysql:// ...

  9. MySQL、Hive以及MySQL Connector/J安装过程

    MySQL安装 ①官网下载mysql-server(yum安装) wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch. ...

随机推荐

  1. Filter 介绍

    Filter 可认为是 Servlet 的一种加强版,它主要用于对用户请求进行预处理,也可以对 HttpServletResponse 进行后处理,是个典型的处理链. Filter 也可对用户请求生成 ...

  2. [linux]linuxI/O测试的方法之dd

    参考http://www.thomas-krenn.com/en/wiki/Linux_I/O_Performance_Tests_using_dd Measuring Write Performan ...

  3. 8.Android_UiAutomator 报告查看

    一.Android UiAutomator报告查看 1.错误类型 1)断言错误:就是断言这个用例的成功或者失败(AssrtionFailedError) 2)脚本错误:UiObjectNotFound ...

  4. 斯皮尔曼等级相关(Spearman’s correlation coefficient for ranked data)

    sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频) https://study.163.com/course/introduction.htm?courseId=1005269003& ...

  5. MVC网站发布到 IIS

    接下来将发布成功的站点部署到iis7.0. 步骤如下: 1. 安装 Microsoft .net FrameWork 4.0安装包(网站开发时候使用的就是.net framework4.0框架); 2 ...

  6. JS自学大全

    JS是从上往下执行的 console.log();输出语句console.warn();错误提示语句 黄色三角形感叹号console.error();错误提示 红色圆Xalert();弹窗docume ...

  7. 树上的构造 树分治+树重心的性质 Codeforces Round #190 (Div. 2) E

    http://codeforces.com/contest/322/problem/E E. Ciel the Commander time limit per test 1 second memor ...

  8. 2-sat Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) D

    http://codeforces.com/contest/782/problem/D 题意: 每个队有两种队名,问有没有满足以下两个条件的命名方法: ①任意两个队的名字不相同. ②若某个队 A 选用 ...

  9. Unsupervised learning, attention, and other mysteries

    Unsupervised learning, attention, and other mysteries Get notified when our free report “Future of M ...

  10. Linux命令学习-图形化界面命令开关闭

    su root password 1, 关闭图形界面: init 3 关闭图形界面(XServer服务也会关闭) 开启图形界面: init 5 或 startx 开机时,不进入 X Window: v ...