今天在写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参数表格附上,以便以后使用:

wKiom1VqsEmRUy6zAAZQCeG_O5E304.jpg

wKiom1VqsEqh7e1_AAZJ3Qppb7s164.jpg

wKioL1VqseCwE4Y6AAafpyHLGGI141.jpg

wKiom1VqsEri9QhIAAX5yrMTUpI793.jpg

wKioL1VqseCxUo0MAAZ3CRztq1E998.jpg

wKiom1VqsErhSFf5AAYgyok2GFs570.jpg

wKioL1VqseGiqtDfAAaTO1LkgZ4057.jpg

wKiom1VqsEuB1EsEAATJo_ozDOY259.jpg