创建实体管理器时映射用户角色

时间:2013-11-01 22:54:14

标签: java persistence firebird entitymanager jaybird

Map properties = new HashMap();
properties.put("javax.persistence.jdbc.driver", "org.firebirdsql.jdbc.FBDriver");
properties.put("javax.persistence.jdbc.url", "jdbc:firebirdsql://localhost:3050/" + DBpath);
properties.put("javax.persistence.jdbc.user", "dbuser");
properties.put("javax.persistence.jdbc.password","dbpassword");
Persistence.createEntityManagerFactory("DB_manager", properties);
DB_ondulatiPUEntityManager = Persistence.createEntityManagerFactory("DB_manager",properties).createEntityManager();

我可以正确创建实体管理器问题是我使用的用户,在DB中授予了特定角色,如何在属性中指定此角色?否则我得到错误 “没有读取/选择访问TABLE的权限......”

1 个答案:

答案 0 :(得分:2)

您可以将它们添加到网址,就像直接通过DriverManager创建连接一样:

properties.put("javax.persistence.jdbc.url", 
   "jdbc:firebirdsql://localhost:3050/" + DBpath + "?roleName=myrole");