Oracle 连接管理器 Java 客户端示例

发布于 2024-09-02 09:49:14 字数 82 浏览 2 评论 0原文

我是 Oracle 连接管理器的新手。有人可以帮助我使用 Java 客户端代码示例来通过 Oracle 连接管理器与 Oracle 数据库进行通信吗?

I am new to Oracle connection manager. Can some help me with a Java Client code example to talk to a oracle database through Oracle connection manager.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫南 2024-09-09 09:49:14

引用自 oracle 文档

运行连接管理器的 Web 服务器位于主机 webHost 上,并正在侦听端口 1610。您要连接的数据库正在主机 oraHost 上运行,侦听端口 1521 和 SID ORCL。您可以采用 TNS 关键字-值格式编写 URL:

String myURL = 
   "jdbc:oracle:thin:@(description=(address_list=
   (address=(protocol=tcp)(port=1610)(host=webHost))
   (address=(protocol=tcp)(port=1521)(host=oraHost)))
   (connect_data=(INSTANCE_NAME=orcl))
   (source_route=yes))";
   OracleDataSource ods = new OracleDataSource();   
   ods.setURL(myURL);   
   ods.setUser("scott");   
   ods.setPassword("tiger");   
   Connection conn = ods.getConnection();

address_list 条目中的第一个元素表示与连接管理器的连接。第二个元素表示您要连接的数据库。列出地址的顺序很重要。

当您的小程序使用上面的 URL 时,它的行为就像直接连接到主机 oraHost 上的数据库一样。

Quote from oracle docs.

The Web server on which the Connection Manager is running is on host webHost and is listening on port 1610. The database to which you want to connect is running on host oraHost, listening on port 1521, and SID ORCL. You write the URL in TNS keyword-value format:

String myURL = 
   "jdbc:oracle:thin:@(description=(address_list=
   (address=(protocol=tcp)(port=1610)(host=webHost))
   (address=(protocol=tcp)(port=1521)(host=oraHost)))
   (connect_data=(INSTANCE_NAME=orcl))
   (source_route=yes))";
   OracleDataSource ods = new OracleDataSource();   
   ods.setURL(myURL);   
   ods.setUser("scott");   
   ods.setPassword("tiger");   
   Connection conn = ods.getConnection();

The first element in the address_list entry represents the connection to the Connection Manager. The second element represents the database to which you want to connect. The order in which you list the addresses is important.

When your applet uses a URL such as the one above, it will behave exactly as if it were connected directly to the database on the host oraHost.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文