[英]check current user has access to database
I log into mysql as root and run 我以root用户身份登录mysql并运行
GRANT SELECT (`creator`, `name`, `disguise`), SHOW VIEW ON `kit` TO 'ssc'@'localhost';
Now from my code I log in as 'ssc'@'localhost'
. 现在,从我的代码中,我以'ssc'@'localhost'
登录。
Connection db = DriverManager.getConnection(..., 'ssc', ...);
How can the user 'ssc'@'localhost'
check that it has the above grant? 用户'ssc'@'localhost'
检查它是否具有上述授予?
I am thinking maybe I can execute some queries in a try
/ catch (SQLException)
block, but perhaps there's a more elegant way. 我在想也许我可以在try
/ catch (SQLException)
块中执行一些查询,但是也许有一种更优雅的方法。
Also if I am to take that approach I don't know what queries would be the most appropriate (fastest, least intensive). 同样,如果我采用这种方法,我也不知道哪种查询最合适(最快,最不密集)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.