前端在向后端发请求查询数据的时候,前端开发者工具提示界面报500的错误,后端run界面显示报错信息
以下是报错的部分提示信息
com.mysql.cj.exceptions.DataConversionException: Unsupported conversion from DATETIME to java.lang.Integer
at com.mysql.cj.result.DefaultValueFactory.unsupported(DefaultValueFactory.java:70) ~[mysql-connector-java-8.0.26.jar:8.0.26]
出现这个错误原因,是因为我的数据库视图表中,在查询语句时,先查询的是时间,然后才是其它类型的数据,具体语句如下所示
select distinct `order`.`otime` AS `otime`,`order`.`oid` AS `oid`,`order`.`sum` AS `sum`,`order`.`cid` AS `cid`,`business`.`bname` AS `bname`,`rider`.`rname` AS `rname`,`delivery`.`detime` AS `detime`,`delivery`.`deidt` AS `deidt`,`address`.`address` AS `address`,`address`.`acontact` AS `acontact`,`address`.`aphone` AS `aphone` from ((((`address` join `order` on((`address`.`aid` = `order`.`aid`))) join `business` on((`order`.`bid` = `business`.`bid`))) join `delivery` on((`order`.`oid` = `delivery`.`oid`))) join `rider` on((`delivery`.`rid` = `rider`.`rid`)))
将时间类放到其它类型的数据之后,前端界面刷新,再次运行就解决上述问题了,具体SQL语句如下所示
select distinct `order`.`oid` AS `oid`,`order`.`otime` AS `otime`,`order`.`sum` AS `sum`,`order`.`cid` AS `cid`,`business`.`bname` AS `bname`,`rider`.`rname` AS `rname`,`delivery`.`detime` AS `detime`,`delivery`.`deidt` AS `deidt`,`address`.`address` AS `address`,`address`.`acontact` AS `acontact`,`address`.`aphone` AS `aphone` from ((((`address` join `order` on((`address`.`aid` = `order`.`aid`))) join `business` on((`order`.`bid` = `business`.`bid`))) join `delivery` on((`order`.`oid` = `delivery`.`oid`))) join `rider` on((`delivery`.`rid` = `rider`.`rid`)))
目前这个问题,解决方法,我只找到了这一种,如果还有其它的解决方法,欢迎各位大神在评论区评论