Reputation: 37
Hi I am trying to configure the quarkus to connect to a oracle database. With the current configuration I am able to connect to the database, but I cannot specify the current schema.
I followed the documentation and try to use the new-connection-sql to set the current schema. But it doesn't seems to work.
quarkus.datasource.mydatasource.new-connection-sql=ALTER SESSION SET CURRENT_SCHEMA=SCHEMA_NAME
Here is my application.properties file
quarkus.datasource.mydatasource.db-kind=oracle
quarkus.datasource.mydatasource.jdbc.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.mydatasource.jdbc.url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.15.73.140)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=SN)))
quarkus.datasource.mydatasource.jdbc.min-size=3
quarkus.datasource.mydatasource.jdbc.max-size=20
quarkus.datasource.mydatasource.username=username
quarkus.datasource.mydatasource.password=password
quarkus.datasource.mydatasource.new-connection-sql=ALTER SESSION SET CURRENT_SCHEMA=SCHEMA_NAME
What could be the issue here?
Thank you.
Upvotes: 1
Views: 3918
Reputation: 565
For Quarkus version 3.3, you can specify schema name through JDBC URL
quarkus.datasource.jdbc.url=jdbc:postgresql://<server>:<port>/<DB_name>?currentSchema=<schema_name>
Upvotes: 0
Reputation: 36
This is working fine if you add the jdbc sub path name to the property
quarkus.datasource.mydatasource.jdbc.new-connection-sql=ALTER SESSION SET CURRENT_SCHEMA=SCHEMA_NAME
You can refer to these Quarkus configuration references:
Upvotes: 2
Reputation: 1762
You could try to set the schema in the connection url. But what you are trying to archieve, basically routing each user request to a specific schema, you should check the hibernate multitenancy support by this means, you can route each request to the database you want, but beware of the limitations regarding the parameters you can work with to know where to route your request.
Also check hibernate catalog and schema configuration parameters
Upvotes: 0