how to check database table permissions in java? (DataBase independently)

Does anyone know a way (in java) to check permissions to a specific table for a user? It has to work on the most Databases. SELECT right is simple to check (just trying to execute a simple SELECT statement), but how to check INSERT permission?


You can use the DatabaseMetaData to get this information. It should work in most cases. However, it might be inaccurate in special cases, if the privileges can not be represented in this abstract way:

DatabaseMetaData metaData connection.getMetaData();

though not a direct solution but the only option that comes to my mind is to use TRY CATCH blocks, issue an INSERT statement and then checking the error message in java.sql.SQLException object returned in case of exception.

Need Your Help

How to match only extensionless URLs? regex url

I want a regex expression which only match extensionless url. In otherwords if an extension is present in url then completely ignore it.

Git Revert Not Working

git undo git-commit

So i've got a develop branch with a commit that I want to revert. So I type in git revert <commit-hash>