MySql str_to_date函数与%Y-%m-%d%H:%i 问题简记
2018-04-11 11:10
113 查看
STR_TO_DATE(concat(c.departure_date, c.departure_time), '%Y-%m-%d%H:%i') < ?)
### Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect datetime value: '2017-05-0818:55:00'
; SQL []; Data truncation: Truncated incorrect datetime value: '2017-05-0818:55:00'; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect datetime value: '2017-05-0818:55:00'
如上异常摘要
软件信息:
mysql版本-select version();
使用mapper版本号如下
问题分析:单独在客户端执行STR_TO_DATE函数 没问题,组合成sql 使用sqltemplate执行也没有问题
那么问题应该就是发生在mapper上了。3.3.0版本的mapper,会因为时间少个秒的单位而报错
即:%Y-%m-%d%H:%i 标识的是年-月-日时分,而实际concat后的结果为2017-05-0818:55:00
因为这个简单的不匹配而报错,很多时候实在是让人抓狂,修改%Y-%m-%d%H:%i为%Y-%m-%d%H:%i%s 即可简单解决问题
### Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect datetime value: '2017-05-0818:55:00'
; SQL []; Data truncation: Truncated incorrect datetime value: '2017-05-0818:55:00'; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect datetime value: '2017-05-0818:55:00'
如上异常摘要
软件信息:
mysql版本-select version();
5.6.23-72.1-log |
<dependency> <groupId>tk.mybatis</groupId> <artifactId>mapper</artifactId> <version>3.3.0</version> </dependency>
问题分析:单独在客户端执行STR_TO_DATE函数 没问题,组合成sql 使用sqltemplate执行也没有问题
那么问题应该就是发生在mapper上了。3.3.0版本的mapper,会因为时间少个秒的单位而报错
即:%Y-%m-%d%H:%i 标识的是年-月-日时分,而实际concat后的结果为2017-05-0818:55:00
因为这个简单的不匹配而报错,很多时候实在是让人抓狂,修改%Y-%m-%d%H:%i为%Y-%m-%d%H:%i%s 即可简单解决问题
相关文章推荐
- TO_DATE函数的小问题
- TO_DATE函数的小问题 --碧水云天
- Oracle中to_date函数的问题
- to_date函数与当前系统时间格式可否隐式转换问题总结
- TO_DATE函数的小问题
- oracal更新日期问题,to_date函数
- MySQL str_to_date函数的使用
- 配置Hadoop集群:java.net.NoRouteToHostException: No route to host问题的解决
- 解决vSphere 5.1上Linux VM提示:Unable to collect IPv4 routing table问题
- Git 使用中显示“Another git process seems to be running in this repository...”问题解决
- eclipse Failed to create the Java Virtual Machine的问题
- ERROR: Can not connect to monitor daemon!的问题
- SVN This client is too old to work with working copy的问题
- (转)解决dubbox-demo-provider.xml报错的问题:提示Failed to read schema document
- 解决android studio ADB无响应的问题:If you'd like to retry,then please manually kill "adb.exe"
- Null value was assigned to a property of primitive type setter问题分析与解决
- 【Android问题】解决 Android SDK下载和更新失败“Connection to https://dl-ssl.google.com refused”的问题
- 在用VSS时遇到的一个问题:Access to file denied 或 Unable to open user login file
- tomcat 6.0.44 “has failed to stop it. This is very likely to create a memory leak” 问题调查
- MySQL远程连接ERROR 2003 (HY000):Can't connect to MySQL server on'XXXXX'的问题