[英]I can't see or edit MySQL stored procedures in NetBeans
I can connect to MySQL database (5.7.23) from NetBeans (8.2) using JDBC (MySQL-AB JDBC Driver, mysql-connector-java-5.1.23).我可以使用 JDBC(MySQL-AB JDBC 驱动程序,mysql-connector-java-5.1.23)从 NetBeans (8.2) 连接到 MySQL 数据库 (5.7.23)。 I can see tables and views, execute SQL statements and everything else with database but I cannot see or edit stored procedures (or functions) in NetBeans.
我可以查看表和视图、执行 SQL 语句以及使用数据库执行的所有其他操作,但我无法查看或编辑 NetBeans 中的存储过程(或函数)。 I have them inside database, I can see and manage them in MySQL Workbench but cannot see them in NetBeans (folder "Procedures" in NetBeans is empty).
我在数据库中有它们,我可以在 MySQL Workbench 中查看和管理它们,但在 NetBeans 中看不到它们(NetBeans 中的文件夹“Procedures”是空的)。 What could be the problem?
可能是什么问题呢?
Left in NetBeans, right in Workbench:左边是 NetBeans,右边是 Workbench:
I have 64-bit Windows 10 Pro (1709), 64-bit NetBeans 8.2 (PHP) and 64-bit MySQL 5.7.14 (from WAMP).我有 64 位 Windows 10 Pro (1709)、64 位 NetBeans 8.2 (PHP) 和 64 位 MySQL 5.7.14(来自 WAMP)。
This is quite annoying that I still haven't found the solution for this problem.这很烦人,我仍然没有找到这个问题的解决方案。 This question is more than one year old.
这个问题已经一年多了。 NetBeans changed from 8.2, 9, 10, now I use 11.2 and still this functionality does not work!
NetBeans 从 8.2、9、10 更改,现在我使用 11.2,但此功能仍然不起作用! I changed MySQL versions, NetBeans versions, JDBC driver versions!!!
我更改了 MySQL 版本、NetBeans 版本、JDBC 驱动程序版本!!! I must be related to regional settings of my machine that disrupts NetBeans!
我一定与我的机器的区域设置有关,这会破坏 NetBeans!
On screenshot one can see that SHOW PROCEDURE STATUS
in NetBeans shows the list of my stored procedures inside database but NetBeans does not show them in navigation tree!在屏幕截图上可以看到 NetBeans 中的
SHOW PROCEDURE STATUS
显示了我在数据库中的存储过程列表,但 NetBeans 没有在导航树中显示它们!
It's really awkward that nobody else encountered this NetBeans strange behaviour.没有其他人遇到这种 NetBeans 奇怪的行为,这真的很尴尬。
There are possibly two reasons:可能有两个原因:
NetBeans uses something like that to get the list of procedures and functions ( see the source code ): NetBeans 使用类似的东西来获取过程和函数的列表( 请参阅源代码):
SELECT
db, name, type, param_list, returns, body
FROM
mysql.proc
WHERE
TYPE = 'PROCEDURE' OR TYPE = 'FUNCTION';
Try to execute the query in NetBeans and see the result.尝试在 NetBeans 中执行查询并查看结果。
See the screenshot.看截图。 On the first one, the user root has access to the mysql schema and you can see all system schemas including the mysql.
在第一个中,用户 root 可以访问 mysql 模式,您可以看到所有系统模式,包括 mysql。 On the second one, the user has access only to the information_schema and performance_schema and can not see procedures and functions:
在第二种情况下,用户只能访问 information_schema 和 performance_schema,不能看到过程和函数:
Try to add to your user access to the MySQL schema.尝试向您的用户添加对 MySQL 架构的访问权限。 In workbench go to Server -> Users and Privileges -> Schema Privileges:
在工作台中转到 Server -> Users and Privileges -> Schema Privileges:
Again, NetBeans uses mysql.pros
extensively to get metadata about procedures and funcstions (see in source code ).同样,NetBeans 广泛使用
mysql.pros
来获取有关过程和函数的元数据(参见源代码)。 I suppose a simple workaround we can get is to create a view that would mimic the behavior of original mysql.proc
:我想我们可以得到一个简单的解决方法是创建一个视图来模仿原始
mysql.proc
的行为:
CREATE VIEW mysql.proc AS
SELECT
ROUTINE_SCHEMA AS db,
ROUTINE_NAME AS name,
ROUTINE_TYPE AS type,
ROUTINE_DEFINITION AS body,
CONCAT(DTD_IDENTIFIER,
' CHARSET ',
CHARACTER_SET_NAME) AS returns,
(SELECT
GROUP_CONCAT(CONCAT(parameter_name, ' ', dtd_identifier))
FROM
information_schema.parameters p
WHERE
p.specific_name = outertable.routine_name
AND ordinal_position > 0) AS param_list
FROM
information_schema.routines outertable
After creating a view we can view procedures and functions from NetBeans 11.2 and view their bodies and param list.创建视图后,我们可以查看 NetBeans 11.2 中的过程和函数,并查看它们的主体和参数列表。 Also, I would not recommend editing procedures using NetBeans because it can't get full metadata.
此外,我不建议使用 NetBeans 编辑过程,因为它无法获得完整的元数据。 For example, it could not get declaration options such as
DETERMINISTIC SQL SECURITY INVOKER
.例如,它无法获得
DETERMINISTIC SQL SECURITY INVOKER
等声明选项。
将 mysql.proc 上的所有权限授予 '<user_name>'@'<host_name>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.