Spring Datasource and Database Schema

后端 未结 3 613
清歌不尽
清歌不尽 2021-01-13 05:40

I am trying to declare a Spring datasource pointing to a DB2 database. Presently I am using a org.springframework.jdbc.datasource.DriverManagerDataSource to setup the connec

3条回答
  •  长发绾君心
    2021-01-13 05:56

    If your connection uses the owner of the schema as the user then that connection will point to that particular schema. ie. If user user1 is the owner of the database schema named schema1 then if you connect to the database using user user1 then by default the connection will point to schema1.

    We have used UserCredentialsDataSourceAdapter provided by spring to connect to different schemas based on the logged in user. This provides a datasource which is pointing to a particular schema based on the user. This uses a thread based login information. Each thread has to decide to which schema it has to connect and provide the user according to that.

提交回复
热议问题