javafirebirdprivilegesjaybird

grant privileges to Firebird user with jaybird


I did succeed in creating a new user in Firebird through FBUserManager.add(user). I did also succeed to connect with the DB I had already created. What I cannot to how is to run queries, I got the message:

"org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544352. no permission for read/select access to TABLE "

What I understood is that the newly created user has not the correct privileges to run the commands. I know how to grant privileges directly in firebird. But I need to do it from java program using jaybird, is anyone aware on how to do it?


Solution

  • There is no API to assign privileges in Jaybird. You will need to execute a series of GRANT statements to assign the required rights just like you would directly in Firebird. Just keep in mind that each GRANT will need to be executed individually using Statement.execute().

    Another options is to assign all rights to a role, assign that role to the user and ensure the role is specified (in the connection string or properties) when connecting to the database. In Firebird 4.0 and higher, you can also assign roles as "default roles", which will result in their privileges being automatically applied even if the role is not explicitly specified on connect.