美文网首页
Mybatis 插入date类型报错解决方案

Mybatis 插入date类型报错解决方案

作者: 墨色尘埃 | 来源:发表于2017-10-12 16:45 被阅读0次

    Mybatis 插入date类型报错解决方案
    oracle中如何插入date类型的数据

    insert into tabname(datecol) value(sysdate) ;  -- 用date值
    insert into tabname(datecol) value(sysdate+1) ;  -- 用date值
    insert into tabname(datecol) value(to_date('2014-02-14','yyyy-mm-dd')) ;  -- 用to_date
    insert into tabname(datecol) value(to_date('2014-02-14 20:47:00','yyyy-mm-dd hh24:mi:ss')) ;  -- 用to_date
    insert into tabname(datecol) value(to_date('20140214','yyyymmdd')) ;  -- 用to_date
    insert into tabname(datecol) value(to_date('20140214204700','yyyymmddhh24miss')) ;  -- 用to_date
    

    使用:
    postman中输入:http://127.0.0.1:10002/New_work_order/baoZhong?workerOrderId=4&userName=1&longitude=1&latitude=1

    插入Date类型到表中.png

    IWorkOrderMapper类中

        @Insert("insert into APP_ORDER_SIGN (WORK_ORDER_ID,USER_ID,DO_TIME,LNG,LAT) values " +
                "( #{workerOrderId,jdbcType=VARCHAR},#{userName,jdbcType=VARCHAR},#{date,jdbcType=TIMESTAMP}, " +
                "#{longitude},#{latitude})")
        /*jdbcType=TIMESTAMP  jdbcType=DATE*/
        void insertBaoZhong(@Param("workerOrderId") String workerOrderId, @Param("userName") String userName,
                            @Param("date") Date date,
                            @Param("longitude") double longitude, @Param("latitude") double latitude);
    

    InstallWorkOrderImp接口实现类

        @Override
        public boolean baoZhong(String workerOrderId, String userName, double longitude, double latitude) {
            Date date = CommonUtil.getNow();
            workOrderMapper.insertBaoZhong(workerOrderId, userName, date, longitude, latitude);
            return true;
        }
    

    xxControl类

        @RequestMapping(value = "/baoZhong", method = RequestMethod.GET)
        ResponseObj<Boolean> baoZhong(@RequestParam String workerOrderId, @RequestParam String userName,
                                      @RequestParam Double longitude, @RequestParam Double latitude) {
            boolean b = installWorkOrderImp.baoZhong(workerOrderId, userName, longitude, latitude);
            return new ResponseObj<>(b, null);
        }
    

    相关文章

      网友评论

          本文标题:Mybatis 插入date类型报错解决方案

          本文链接:https://www.haomeiwen.com/subject/ctdoyxtx.html