簡體   English   中英

將 spring boot 連接到 oracle 雲數據庫(如果可能,使用 url)

[英]Connect spring boot to oracle cloud database (with url if possible)

我正在嘗試使用 spring-boot 做我的第一個后端。 我在 Oracle Cloud 上使用數據庫。
事情是連接每個人都使用spring.datasource.url=jdbc:oracle:thin:@ip:port 問題是我完全迷失在 Oracle 雲儀表板中,找不到 URL。 我只有一個錢包(我用它來將數據庫連接到 intellij 和 Oracle Sql Developer)。 我的數據庫是“永遠免費”的,所以它可能沒有 URL,只能與錢包連接。 那么我必須在我的 spring-boot 項目中連接錢包嗎? 我怎么做 ?
那我應該把錢包放在哪里?
抱歉,我有很多問題,但 Oracle 雲對我來說並不清楚。
謝謝您的幫助 !

您是否配置了自治數據庫,也就是 ATP? 您可以通過從儀表板頁面轉到數據庫服務來找到連接字符串。

  1. 轉到數據庫服務
  2. 單擊左側菜單中的自治數據庫
  3. 從列表中選擇您的數據庫以進入自治數據庫詳細信息頁面
  4. 單擊此處紅色框中標記的DB Connection按鈕。

數據庫連接

  1. 這將顯示右側的“連接”面板,您可以在其中向下滾動錢包部分以查找連接字符串。

ATP 連接字符串

您可以復制連接字符串。 它應該向您顯示如下內容:

(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.region-x-1.oraclecloud.com))(connect_data=(service_name=xxxx_abcdb123_tp.adb.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adb.region-x-1.oraclecloud.com, OU=Oracle ADB, O=Oracle Corporation, L=Redwood City, ST=California, C=US")))

現在,正如你在這里看到的。 端口號為1522 ,服務名稱為xxxx_abcdb123_tp.adb.oracle.com

所以這就是我解決它的方法。 我將此添加到我的 pom.xml 中。 希望它會有所幫助

    <dependency>
        <groupId>com.oracle.database.jdbc</groupId>
        <artifactId>ojdbc10</artifactId>
        <version>19.11.0.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.oracle.database.security</groupId>
        <artifactId>oraclepki</artifactId>
        <version>21.5.0.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.oracle.database.security</groupId>
        <artifactId>osdt_cert</artifactId>
        <version>21.5.0.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.oracle.database.security</groupId>
        <artifactId>osdt_core</artifactId>
        <version>21.5.0.0</version>
        <scope>runtime</scope>
    </dependency>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM