简体   繁体   English

将 spring boot 连接到 oracle 云数据库(如果可能,使用 url)

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

I'm trying to do my first backend with spring-boot.我正在尝试使用 spring-boot 做我的第一个后端。 I'm using a Database on Oracle Cloud.我在 Oracle Cloud 上使用数据库。
The thing is to connect everyone uses spring.datasource.url=jdbc:oracle:thin:@ip:port .事情是连接每个人都使用spring.datasource.url=jdbc:oracle:thin:@ip:port The thing is I'm completely lost in Oracle cloud dashboard and I can't find the url.问题是我完全迷失在 Oracle 云仪表板中,找不到 URL。 I only have a wallet (which I use to connect the DB to intellij and Oracle Sql Developer).我只有一个钱包(我用它来将数据库连接到 intellij 和 Oracle Sql Developer)。 My DB is a "always free" so maybe it doesn't have an url and can only connect with the wallet.我的数据库是“永远免费”的,所以它可能没有 URL,只能与钱包连接。 So do I have to connect with wallet within my spring-boot project ?那么我必须在我的 spring-boot 项目中连接钱包吗? How do I do that ?我怎么做 ?
Where shall I put the wallet then ?那我应该把钱包放在哪里?
Sorry I have so many questions but Oracle cloud isn't clear to me.抱歉,我有很多问题,但 Oracle 云对我来说并不清楚。
Thanks for the help !谢谢您的帮助 !

Did you provision autonomous database, aka ATP?您是否配置了自治数据库,也就是 ATP? You can find connect string by going to Databases services from the dashboard page.您可以通过从仪表板页面转到数据库服务来找到连接字符串。

  1. Go to the Database services转到数据库服务
  2. Click Autonomous Database in the left hand menu单击左侧菜单中的自治数据库
  3. Pick your DB from the list to get to the Autonomous Database Details Page从列表中选择您的数据库以进入自治数据库详细信息页面
  4. Click on the DB Connection button marked in the red box here.单击此处红色框中标记的DB Connection按钮。

数据库连接

  1. This will bring out the Connections panel on the right, where you can scroll down below the wallet section to find the connect strings.这将显示右侧的“连接”面板,您可以在其中向下滚动钱包部分以查找连接字符串。

ATP 连接字符串

You can copy the connect string.您可以复制连接字符串。 It should show you something like this:它应该向您显示如下内容:

(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")))

Now, as you can see here.现在,正如你在这里看到的。 Port number is 1522 and the service name is xxxx_abcdb123_tp.adb.oracle.com端口号为1522 ,服务名称为xxxx_abcdb123_tp.adb.oracle.com

So here is how I solved it.所以这就是我解决它的方法。 I added this to my pom.xml.我将此添加到我的 pom.xml 中。 Hope it will help希望它会有所帮助

    <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