I am trying to test the connection to a db
jdbc:oracle:thin:@//xxx:1521/ORCLPDB1 – it works to connect to the cloud db via port forwarding
jdbc:oracle:thin:@//xxx:1521/ORCLCDB – it does not work to connect to the cloud db via port forwarding
However I read that the ORCLCDB (SID) shoud be specified in the flyway config and spring. datasource url
Can someone explain the differences between the two and which should I us in the spring aplication properties
spring:
datasource:
url: jdbc:oracle:thin:@//xxx:1521/ORCLPDB1
flyway:
locations: classpath:/db/migration/oracle
url: jdbc:oracle:thin:@//xxx:1521/ORCLPDB1
>Solution :
The two database connection URLs you mentioned, jdbc:oracle:thin:@//xxx:1521/ORCLPDB1 and jdbc:oracle:thin:@//xxx:1521/ORCLCDB, correspond to different Oracle database instances. Let’s break down the differences and clarify their usage:
-
jdbc:oracle:thin:@//xxx:1521/ORCLPDB1: This URL connects to an Oracle Pluggable Database (PDB) named "ORCLPDB1." In Oracle Multitenant architecture, the Container Database (CDB) can host multiple PDBs. The PDBs act as separate databases within the CDB. This URL is used when you want to connect directly to the specific PDB. -
jdbc:oracle:thin:@//xxx:1521/ORCLCDB: This URL connects to the Container Database (CDB) itself, rather than a specific PDB. The CDB is the main database that contains multiple PDBs. When connecting to the CDB, you have access to manage and administer all the PDBs within it. This URL is typically used when you need to perform administrative tasks or access features at the CDB level.
Now, regarding your Spring application properties and Flyway configuration, the choice of which URL to use depends on your application’s requirements:
-
If your application needs to interact with a specific PDB, such as executing SQL statements or performing data access operations within that PDB, you should use
jdbc:oracle:thin:@//xxx:1521/ORCLPDB1as thespring.datasource.urlproperty in your Spring application properties file. Similarly, in your Flyway configuration, you should use the same URL in theurlproperty. -
On the other hand, if your application requires administrative access or needs to perform tasks at the CDB level, you can use
jdbc:oracle:thin:@//xxx:1521/ORCLCDBas thespring.datasource.urlproperty. However, note that this URL might require additional privileges or permissions to perform certain operations.
Remember to replace xxx with the appropriate host or IP address for your Oracle database server.
In summary, choose the URL based on whether you need to interact with a specific PDB (ORCLPDB1) or the overall CDB (ORCLCDB), and use the corresponding URL in your Spring application properties and Flyway configuration accordingly.