简体   繁体   English

Oracle Connection Manager Java客户端示例

[英]Oracle connection manager Java Client example

I am new to Oracle connection manager. 我是Oracle连接管理器的新手。 Can some help me with a Java Client code example to talk to a oracle database through Oracle connection manager. 可以通过Java客户端代码示例帮助我,以通过Oracle连接管理器与oracle数据库进行通信。

Quote from oracle docs . 引用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. 运行连接管理器的Web服务器在主机webHost上,并且正在侦听端口1610。要连接到的数据库在主机oraHost上运行,在端口1521和SID ORCL上侦听。 You write the URL in TNS keyword-value format: 您以TNS关键字值格式编写网址:

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. address_list条目中的第一个元素表示与连接管理器的连接。 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. 当您的小程序使用上述URL之类的URL时,它的行为就如同直接连接到主机orHost上的数据库一样。

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

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