views:

154

answers:

1

Hi Experts, I am new to oracle connection manager. Can some help me with a Java Client code example to talk to a oracle database thru oracle connection manager.

Thanks Sam.

A: 

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.

Robert Merkwürdigeliebe