通过JDBC 执行SQL 语句 在 TIDB 4.0 下出现 java.sql.SQLException: ResultSet is from UPDATE. No Data. 错误

通过JDBC 执行SQL 语句 在 TIDB 4.0 下出现 java.sql.SQLException: ResultSet is from UPDATE. No Data. 错误,tidb 2.0 没有这样的错误 ,我们去掉 set @days := 0 ,@last_createDate := ‘’ ,@last_bookId := 0 ,@ix := 0; 这一段在 TIDB 4.0下没有这个问题了。在命令行下执行如下sql语句在 TIDB 4.0下也没有问题

我们现在判断 set @days := 0 ,@last_createDate := ‘’ ,@last_bookId := 0 ,@ix := 0; 这句话被 TIDB 4.0当成 ResultSet返回了。

sql如下
set @days := 0 ,@last_createDate := ‘’ ,@last_bookId := 0 ,@ix := 0;
select bookId,IF(CURDATE()=date_sub(curdate(),interval WEEKDAY(curdate()) day),concat(DATE_FORMAT( DATE_SUB( DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY), INTERVAL 1 WEEK), ‘%Y%m%d’),CURDATE()-1),CONCAT(DATE_FORMAT(date_sub(curdate(),interval WEEKDAY(curdate()) day),’%Y%m%d’),DATE_FORMAT(DATE_ADD(curdate(),INTERVAL 6-WEEKDAY(curdate()) day),’%Y%m%d’))) as effectDate, IF(date_format(end_date,’%Y%m%d’)=CURDATE()-1,SUBSTRING_INDEX(GROUP_CONCAT(maxdays SEPARATOR ’ ‘),’ ',1),‘0’) as continuousUpdatingDays,CURRENT_TIMESTAMP() as updateTime from (select bookId,max(cast(days as UNSIGNED)) as maxdays,min(createTime_date) as start_date,max(createTime_date) as end_date from (select bookId,@days:=(CASE WHEN (bookId = @last_bookId and DATEDIFF(createDate,@last_createDate) = 1) THEN (@days + 1) WHEN (bookId = @last_bookId and createDate = @last_createDate) THEN (@days + 0) ELSE cast(1 as unsigned) END) as days,@ix:=(@ix + IF(@days=1,1,0)) as ix, @last_bookId:=bookId as book_id,@last_createDate:=createDate as createTime_date from (select bookId,DATE(createTime) as createDate from book_continuous_updating where date(createTime)>=IF(CURDATE()=date_sub(curdate(),interval WEEKDAY(curdate()) day),DATE_FORMAT( DATE_SUB( DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY), INTERVAL 1 WEEK), ‘%Y-%m-%d’),date_sub(curdate(),interval WEEKDAY(curdate()) day)) and date(createTime)<curdate() group by bookId,DATE(createTime) order by bookId,createTime) t1) t group by bookId,ix order by bookId,end_date desc) ttt group by bookId

1赞

看下这里呢 https://github.com/alibaba/druid/issues/2091 看类似的报错解决方法比较多,整体看下来,跟 TiDB 关系不大。