简体   繁体   English

Oracle Cloud Infrastructure (OCI) 上的直接数据库连接

[英]Direct database connection on Oracle Cloud Infrastructure (OCI)

I got a free Oracle Cloud Infrastructure (OCI) service from Oracle for two months.我从 Oracle 获得了两个月的免费Oracle 云基础设施 (OCI)服务。 I would like to create an Oracle database and connect to it directly over the inte.net (I don't want to create a VPN tunnel).我想创建一个 Oracle 数据库并直接通过 inte.net 连接到它(我不想创建 VPN 隧道)。

Do you know how I should do it?你知道我该怎么做吗?

One way to do it, use this URL pattern:一种方法是使用此 URL 模式:

jdbc:oracle:thin:/@OCI_DB_NAME_high?TNS_ADMIN=PATH_TO_THE_WALLET_FOLDER

user name and password as usual, the Wallet should be unzipped.像往常一样输入用户名和密码,钱包应该被解压缩。

Properties info = new Properties();     
info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER);
info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD);          
... 

OracleDataSource ods = new OracleDataSource();
ods.setURL(DB_URL);    
ods.setConnectionProperties(info);

OracleConnection connection = (OracleConnection) ods.getConnection();

I solved the problem myself.我自己解决了这个问题。

To get to the database server without configuring a VPN link, you can create a virtual machine accessible via an external IP address and ssh from it to a local address from the 10.0.0.0 network要在不配置 VPN 链接的情况下访问数据库服务器,您可以创建一个可通过外部 IP 地址访问的虚拟机,然后从 10.0.0.0 网络通过 ssh 连接到本地地址

Here is the Spring Boot sample to connect to OCI managed autonomous database.这是连接到 OCI 管理的自治数据库的 Spring 引导示例。

https://github.com/oracle-devrel/oci-sdk-java-samples/tree/main/usecases/connect-autonomous-database https://github.com/oracle-devrel/oci-sdk-java-samples/tree/main/usecases/connect-autonomous-database

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM