A. METODOLOGÍA DEL PROYECTO
2.2. Diagnóstico social
Connection Manager is a lightweight, highly scalable, middle-tier program that receives and forwards Net8 packets from one source to another. When Connection Manager resides on the same host as a web server, an applet can get around the network connection restriction of the sandbox by making a connection to Connection Manager, which will in turn forward any Net8 requests on to the appropriate database listener. As I stated in Chapter 2, you can classify the combined use of Oracle's Thin driver together with Connection Manager as a Type 3 driver. To use Connection Manager, you must install it on the same host as your applet's web server. Then you must use a special form of database URL. And you thought we had covered every possible type didn't you? First, let's cover Connection Manager's installation.
3.4.1.1 Installing Connection Manager
Installing Connection Manager is a simple process involving the following steps:
1. Install Connection Manager from the Oracle Enterprise Edition original distribution CD. 2. Create a configuration file.
3. Start Connection Manager by executing cmctl start.
Follow your operating system's specific instructions to run the Oracle Universal Installer from the original distribution CD. You must choose Install and then select a Custom Install. Next, browse through the uninstalled products list until you find Oracle Connection Manager. Select it and then proceed through the installation following the instructions on the screen.
After you're done installing Connection Manager, look in your
$ORACLE_HOME\network\admin\sample directory for a file named cman.ora. That file will be a template of a Connection Manager configuration file. Copy the cman.ora file to
$ORACLE_HOME\network\admin. This will give you a default configuration for Connection Manager that uses TCP/IP port 1630 for your JDBC connection. Port 1830 will be used for Connection Manager's administrator program, which is named cmctl. The default configuration file contains a large number of comment lines. Example 3-3 shows only the uncommented lines so you can easily see the port number assignments.
Example 3-3. The default Connection Manager configuration file
cman = (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1630)(QUEUESIZE=32)) ) cman_admin = (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1830)) cman_profile = (parameter_list= (MAXIMUM_RELAYS=1024) (LOG_LEVEL=1) (TRACING=yes) (TRACE_DIRECTORY=C: \Oracle\Ora81\Network\Log) (RELAY_STATISTICS=yes) (SHOW_TNS_INFO=yes) (USE_ASYNC_CALL=yes) (AUTHENTICATION_LEVE L=0) (REMOTE_ADMIN=FALSE) )
If you need to reconfigure Connection Manager to use a different set of ports, modify the PORT=
item for the cman and cman_admin listening addresses in your cman.ora file. Remember to use your new cman port setting in your JDBC database URL.
Finally, to start Connection Manager, execute the command cmctl start. Now, your last step in utilizing Connection Manager is to formulate a database URL.
3.4.1.2 Formulating a database URL for Connection Manager
When you formulate a database URL for Connection Manager, you're essentially combining an address to Connection Manager with an address to a database. You will use Oracle's Net8 Transparent Network Substrate (TNS) keyword-value syntax to pass two addresses to the Thin driver -- the Net8 keyword-value syntax is the only means of specifying more than one address in a URL. The first address will be for the web server host. The second will be for your target database. Since the second address is for a database, it will also specify an Oracle SID.
Formulating a database URL for Connection Manager is where most of the problems using Connection Manager occur. For the most part, a URL for Connection Manager has the same general format as you saw in Chapter 2:
jdbc:oracle:thin:@database
When you're connecting through Connection Manager, the database portion of the URL takes on the following form:
(description=(address_list=
(address=(protocol=tcp)(host=webhost)(port=1630)) (address=(protocol=tcp)(host=orahost)(port=1521))) (source_route=yes)(connect_data=(sid=orasid)))
which breaks down as:
webhost
The TCP/IP address, or DNS alias, for your web server's host.
1630
The Connection Manager port number specified in cman.ora. 1630 is the default value.
orahost
The TCP/IP address, or DNS alias, for your target database's host.
1521
The Net8 listener port number as specified in the listener.ora file on your database server. 1521 is the default listener port.
orasid
The Oracle SID for your target database.
For example, if your web server's alias is dssw2k01, your database server's alias is dssnt01, and your database SID is dssora01, then you should use the following Connection Manager URL:
jdbc:oracle:thin:@
(description=(address_list=
(address=(protocol=tcp)(host=dssw2k01)(port=1630)) (address=(protocol=tcp)(host=dssnt01)(port=1521))) (source_route=yes)(connect_data=(sid=dssora01)))
Modify the connection statement of TestApplet from Example 3-1 to incorporate this new
URL, and the resulting statement will look like this:
conn = DriverManager.getConnection( "jdbc:oracle:thin:" + "@(description=(address_list=" + "(address=(protocol=tcp)(host=dssw2k01)(port=1630))" + "(address=(protocol=tcp)(host=dssnt01)(port=1521)))" + "(source_route=yes)" + "(connect_data=(sid=dssora01)))","scott","tiger");
Connection Manager can also be used as a connection concentrator or as a firewall. Multiple Connection Manager addresses can be specified prior to your database server address and SID to create a chain of Connection Manager connections. In other words, you can route a connection through any number of Connection Manager instances. For more information on Connection Manager installation, configuration, and use, see Oracle's Net8 Administrator's Guide, which is available on the OTN, or Oracle Net8 Configuration and Troubleshooting, by Hugo Toledo and Jonathan Gennick (O'Reilly).
If you think using Connection Manager sounds like a lot of work, wait until you learn about the other workaround option: getting socket permissions.