Recipe 21.4 Creating a DataSource on WebLogic
You want to
create a javax.sql.DataSource
on BEA WebLogic for use in your servlets.
Use the WebLogic console to configure a new connection pool, then
configure a new DataSource associated with that
Configuring a WebLogic DataSource involves the
Login to the WebLogic console, which allows you to manage
the WebLogic server from a browser. The URL for the console is
(substitute your host name for
"localhost" and the port number
that matches your own WebLogic configuration).
Click on Your-domain-name
Services JDBC Connnection Pools on the menu
tree in the console's lefthand column. Then click on
"Configure a new JDBC Connection Pool . . .
In the resulting window, enter a name for the connection pool, the
JDBC URL (e.g.,
Driver class name (e.g.,
oracle.jdbc.driver.OracleDriver), as well as the
username and password in the
"Properties" text field. Figure 21-2 shows a configured connection pool named
"OraclePool." Remember this
name—you'll need it to configure a
DataSource further along in the process.
Figure 21-2. Creating a connection pool with the WebLogic console application
Click on the "Create" button in
this window to create the connection pool, then choose the
"Targets" tab. The resulting screen
allows you to choose a server to which the connection pool will
apply. After you have chosen the server, click on the
"Apply" button in the Targets
screen. The name of the new pool should appear in the lefthand menu
Click on Your-domain-name
Services JDBC Data Sources and click on the URL
"Configure a New JDBC Data Source . . .
". Figure 21-3 shows a
DataSource configuration window that includes the
("oracle-8i-athletes") under which
WebLogic will bind the DataSource as a JNDI
object. The window also has a text field where you must enter the
name of the connection pool that you just configured:
"OraclePool." Click the
"Create" button to create the new
DataSource. Figure 21-3 shows the JDBC Data Sources
Take the same steps as in step 4 with the
"Targets" screen to apply this
DataSource to the appropriate server. Painless,
Figure 21-3. Creating a DataSource with the WebLogic console application
Figure 21-4 shows the WebLogic
tree where the DataSource that you have just
created is bound.
Figure 21-4. A view of the WebLogic JNDI tree containing the DataSource
The JDBC specification: http://java.sun.com/products/jdbc/download.html;
Chapter 2 on deploying servlets and JSPs on
WebLogic; Recipe 21.2 and Recipe 21.3 on using a
DataSource on Tomcat; Recipe 21.5 and Recipe 21.6 on using DataSources with
servlets and JSPs on WebLogic.