简体   繁体   English

如何检查用户是否具有对Java中数据库的写访问权

[英]how to check if user has write access to a database in java

I want to check if the user has write access permission to given database and server name using java. 我想检查用户是否具有使用java对给定数据库和服务器名称的写访问权限。

I am using Sybase database 我正在使用Sybase数据库

for example 例如

server :ABC_server 服务器:ABC_server

db: xx_db 分贝:xx_db

I want to check basically the user is in "read-write" group. 我想基本上检查用户是否在“读写”组中。 if he is in that group, he will definitely have access to read and write permissions. 如果他属于该组,则他绝对有权访问读写权限。

Generally speaking database permissions can begin from database/schema level permissions to specific table and column level select/insert/update permissions. 一般来说,数据库权限可以从数据库/架构级别的权限到特定的表和列级别的选择/插入/更新权限开始。 Different databases have different levels. 不同的数据库具有不同的级别。 If you want to know whether a user has permission at any level you can do one of these: 如果您想知道用户是否具有任何级别的权限,可以执行以下任一操作:

  1. Query the system tables where the database stores the permission data. 查询数据库存储许可数据的系统表。
  2. Try to run the operation. 尝试运行该操作。 Operation error indicates that permission is not granted. 操作错误指示未授予权限。

Typically system table access is limited to admin users only. 通常,系统表访问仅限于管理员用户。 Therefore No. 1 is not an option. 因此1号不是一个选择。 Then you will be left with only No. 2. Try the operation on the database and table of your interest. 然后,您将只剩下2号。尝试对您感兴趣的数据库和表进行操作。 If the operation fails you know the user has no permission. 如果操作失败,您将知道用户没有权限。 If the operation succeeds you may have to roll back the changes done if the operation was insert/update. 如果操作成功,则如果操作是插入/更新,则可能必须回滚所做的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检查当前用户有权访问数据库 - check current user has access to database 如何检查我的Firebase数据库是否具有特定用户的数据? (Android / Java) - How can I check if my Firebase database has data for a certain user? (Android/Java) Android / Java-如何检查OutputStream完成写入字节的时间 - Android/Java - How check when the OutputStream has finished to write the bytes Java:jSpinner:写入Access数据库? - Java: jSpinner: Write to Access Database? 如何检查某个用户是否具有读者对文档的访问权限 - How to check if a certain user has reader-access to a document 在Java中,如何检查用户是否输入了另一个数字: - How To Check, In Java, If User Has Inputted Another Number: Java-如何检查数据库中的现有用户(用于注册界面)? - Java - How to check an existing user in the database (for a signup interface)? 如何通过从 GUI 获取用户输入并将该用户输入存储到 java 中的数据库中来写入数据库? - How do i write to a database by taking user input from a GUI and storing that user input into a database in java? 如何获取特定用户是否在根节点上具有{写入,读取}权限 - How to get check if a certain user has {Write, read} permissions on a root node 使用Rally API如何查找用户具有写权限的所有项目? - Using Rally API how to find all the projects for which the user has write access?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM