今天在写Java项目使用了
1
2
3
4
5
6
7
8
9
10
11
12
|
<
select
id=
"getPlans"
parameterType=
"hashMap"
resultType=
"hashMap"
>
SELECT
*
FROM
`plan`
WHERE
isDelete=#{isDelete}
AND
nestId
in
<foreach collection=
"nestIds"
item=
"nestId"
index
=
"index"
open
=
"("
close
=
")"
separator=
","
>
#{nestId}
</foreach>
</
select
>
|
但是很不幸,后台报异常:
1
|
java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
|
经过查找才发现是因为数据表有的addTime是“0000-00-00 00:00:00”,不论是Mybatis还是hibernate都认为不是一个有效的时间字串,而有效的日期格式为"2015-05-29 21:23:07"。
此时,可以为:
1
2
3
4
5
6
7
8
9
10
11
12
|
<
select
id=
"getPlans"
parameterType=
"hashMap"
resultType=
"hashMap"
>
SELECT
`planId`, `type`, `planName`, `userId`, `nestId`, `userStatus`, `budgetStatus`, `budget`, `
rule
`, `isDelete`
FROM
`plan`
WHERE
isDelete=#{isDelete}
AND
nestId
in
<foreach collection=
"nestIds"
item=
"nestId"
index
=
"index"
open
=
"("
close
=
")"
separator=
","
>
#{nestId}
</foreach>
</
select
>
|
但是在另一个SQL中只能使用“*”,所以我只能查找解决方法了。
经过查看官方文档和百度搜索。
记得可以使用
jdbc:mysql://localhost:3306/solr?characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull&useUnicode=true
解决!
所以我将Mysql JDBC Url参数表格附上,以便以后使用:
版权声明:原创作品,如需转载,请注明出处。否则将追究法律责任
本文转自 梦朝思夕 51CTO博客,原文链接:http://blog.51cto.com/qiangmzsx/1656852