数据库参数导致Prepared statement needs to be re-prepared

1.问题描述

在查询视图时,执行存储过程时Java代码报错:java.sql.SQLException: Prepared statement needs to be re-prepared;单独调用存储过程也是报错:Prepared statement needs to be re-prepared,代码和存储过程没问题;这是数据库设置问题。

2.问题排查

mysql的变量值设置不合理,原有的存储过程里增加了个 左链接 控制台抛出 Prepared statement needs to be re-prepared 异常 数据库交换空间已满 alt

3.问题解决

  1. 查看 table_open_cache 量 mysql 的两个全局变量(打开表的缓存数量,表定义缓存数量)的设置值过小,而你的数据库表数量较多的情况。
1、打开表的缓存数量(table_open_cache)查询sql:
  SHOWVARIABLESLIKE'%table_open_cache%';
       
2、表定义缓存数量(table_definition_cache) 查询sql : 
  SHOWVARIABLESLIKE'%table_definition_cache%'; 

  1. mysql引起的错误,设置
  • set global table_open_cache=16384; 表描述符缓存大小
  • set global table_definition_cache=16384;
全部评论

相关推荐

11-13 10:17
门头沟学院 Java
昨天面美团,jvm,juc问的好深啊,感觉小林coding不太够喔,牛油们有没有什么推荐的八股网站嘛🕒 岗位/面试时间👥 面试题目🤔 面试感受
明天不下雨了:小林Coding:https://xiaolincoding.com/ 全栈哥:https://www.pdai.tech/ Guide哥:https://javaguide.cn/ 秀哥:https://interviewguide.cn/ 沉默王二:https://javabetter.cn/home.html 磊哥:https://www.javacn.site/interview/basic/ 小傅哥:https://bugstack.cn/ 源码哥:https://doocs.github.io/source-code-hunter/#/ 各大厂的公众号技术文章和一些经典的书籍
面试太紧张了怎么办?
点赞 评论 收藏
分享
10-13 13:49
南京大学 财务
饿魔:笑死我了,你简直是个天才
点赞 评论 收藏
分享
10-17 17:54
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务