MYSQL驱动包升级到5.1.17版本之后会出现的问题:Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.execu
来源:互联网 发布:阿里云ddos防御 编辑:程序博客网 时间:2024/06/07 09:43
今天部署项目的时候顺便把一些依赖用新版本的jar替换了,其他还好就是MYSQL的驱动出了问题。
原来用的是5.1.5的包,替换成5.1.17之后,如下生成主键的代码都会报错:
Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate() or Connection.prepareStatement().
据说要修改成这样才不会报错:
原因是:貌似从5.1.7版本之后的mysql-connector增加了返回GeneratedKeys的条件,如果需要返回GeneratedKeys,则PreparedStatement需要显示添加一个参数Statement.RETURN_GENERATED_KEYS。不过直接报错,不向下兼容也太不厚道了。
相关Bug信息:http://bugs.mysql.com/bug.php?id=41448
参考:http://www.itsmile.net/blog/article_show/20/273752
- MYSQL驱动包升级到5.1.17版本之后会出现的问题:Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.execu
- 更新mysql驱动5.0-6.0 Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS
- 【JavaEE】SQLException:Generated keys not requested. You need to specify Statement.RETURN_GE
- java.sql.SQLException: Generated keys not requested. You need to ... 错误
- Android SDK 升级到ADT 17 以上版本出现dalvikvm: Unable to resolve superclass的问题
- Could not find SQL statement to include with refid :XXX这样的问题
- Statement.RETURN_GENERATED_KEYS 获取自动增加的id号
- 会出现unreachable statement的可能
- Caused by: java.sql.SQLException: Generated keys not requested
- ibatis Could not find SQL statement to include with refid 'xxx' 问题。
- ibatis Could not find SQL statement to include with refid 'xxx' 问题
- ibatis Could not find SQL statement to include with refid 'xxx' 问题
- ibatis Could not find SQL statement to include with refid 'xxx' 问题
- 使用PD时,出现you need to install VBScript before you can run scripts的解决方案
- PowerDesigner出现you need to install VBScript before you can run scripts的解决办法
- PowerDesigner出现you need to install VBScript before you can run scripts的解决办法
- 用sqlite是出现Unable to prepare statement: 1警告
- ibatis中Could not find SQL statement to include with refid的原因
- git 学习
- ASP.NET程序如何防止被注入(整站通用)
- 记一次算法比较
- 浅拷贝与深拷贝
- GroupBox 篇
- MYSQL驱动包升级到5.1.17版本之后会出现的问题:Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.execu
- 数值计算相关工具(C#篇)
- warning: backslash and newline separated by space
- 大家很容易忽视的几个问题,1.投简历请换位思考、2.前台页面设计比后台实现更值钱
- 给dsoframer.csx制作CAB安装包
- solaris配置IP地址过程
- [摘錄]IOCP相關知識
- exchange 2010在WIndows 2008R2上部署安装时的一些重要点图片
- JS执行link