当前位置:Gxlcms > 数据库问题 > Mysql JDBC Url参数与异常问题

Mysql JDBC Url参数与异常问题

时间:2021-07-01 10:21:17 帮助过:51人阅读

<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>

但是很不幸,后台报异常:

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"。

此时,可以为:

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

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享



本文出自 “梦朝思夕” 博客,请务必保留此出处http://qiangmzsx.blog.51cto.com/2052549/1656852

Mysql JDBC Url参数与异常问题

标签:mysql jdbc

人气教程排行