Search code examples
oracle-databasespring-bootconnectionspring-jdbc

Oracle Editions and Spring boot


I am using spring boot and spring-jdbc-starter.

I am trying to connect to specific edition in oracle database. For example, it is EDITION_X.

Then, I am trying to create a datasource via yaml file.

spring:
  datasource:
    driverClassName: oracle.jdbc.driver.OracleDriver
    url: jdbc:oracle:thin:@ip:port/NAME
    username: user
    password: password
    connectionProperties:
      - ORA_EDITION:EDITION_X

Another way, I am trying to configure it via java-code.

    public DataSource oracleDataSource() throws SQLException {
        OracleDataSource oracleDataSource = new OracleDataSource();
        Properties properties = new Properties();
        properties.setProperty("ORA_EDITION", "EDITION_X");
        oracleDataSource.setConnectionProperties(properties);
        oracleDataSource.setURL("jdbc:oracle:thin:@ip:port/NAME");
        oracleDataSource.setUser("user");
        oracleDataSource.setPassword("");
        oracleDataSource.setDriverType("oracle.jdbc.driver.OracleDriver");
        return oracleDataSource;
    }

From actuator, it seems, that properties are loaded. But the edition is still default.

Any ideas, how to connect to specific edition in oracle database?


Solution

  • In poor JDBC connection you should provide "oracle.jdbc.editionName" propertie. In spring it also should work.

    properties.setProperty("oracle.jdbc.editionName", "EDITION_X");

    If you one the check if it's work use this query.

    select sys_context('userenv', 'current_edition_name') from dual