I have a Java webapp (WAR) that is to be run in JBOSS.
That webapp is to create connections to an Oracle database using a username/password for a user that is given read-only permissions.
The webapp queries tables belonging to a different schema. I do this by qualifying each table name in my SQL queries.
However, I would like to parameterise this in my datasource, since the schema names can be different in different environments.
Is there a way to define a JBOSS data source which logs in as User A for each connection, but uses Schema B for all queries?
一种方法是使用new-connection-sql
或check-valid-connection-sql
数据源属性执行ALTER SESSION SET CURRENT_SCHEMA=yourschema
,这将更改每个连接的默认架构。
推荐的方法是在Oracle中为用户A创建同义词,以访问用户B拥有的架构中的表。通过这种方式,您甚至可以授予用户A特定的特权,以选择,更新,插入另一个UserB拥有的表。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.