How Do I: Connect a Database Control to a Database Such as SQL Server or Oracle?

WebLogic Server manages the databases you can use and allows you to access configured databases through JDBC data sources. If you wish to use a new database, there must be a JDBC connection pool and data source set up that allows you to access that database. You can set up a new connection pool and data source in the WebLogic Server console.

WebLogic Server includes pre-configured drivers for accessing Microsoft SQL Server and Oracle. These drivers are listed in the WebLogic Server console. If you want to use a driver other than one of the recommended drivers, you may need to install the driver yourself and add it to your class path.

To Change the Data Source Used by a Database Control

  1. In Design View, click the Database control your service will use to access the database.
  2. In the Property Editor window, expand the connection property if it is not already expanded.
  3. In the data-source-jndi-name field, enter the value corresponding to the data source you want to use.

To Access the WebLogic Server Console

You can use the WebLogic Server console to configure a new connection pool and data source in WebLogic Server. If you are running WebLogic Workshop and WebLogic console on the same computer, you can access the console as shown in the following procedure. Otherwise, check with your system administrator to configure WebLogic Server.

  1. Launch the console by navigating to http://localhost:7001/console/.
  2. Provide your user name and password; by default, for the Workshop domain server both are set to weblogic.

    Note. For more information, see How Do I: Administer WebLogic Server Through the Administration Console?

Next, you must create a new connection pool.

To Create a New Connection Pool

  1. In the Weblogic Server Console, click Connection Pools in the JDBC section of Service Configurations.
  2. Click Configure a new JDBC Connection Pool.
  3. Choose the Database Type and Database Driver. Click Continue.
  4. Fill in the following fields and click Continue:
  5. On the Test database connection page, a summary is given of the configuration information at this point. Click Test Driver Configuration to test whether the database connection is properly configured.
  6. If there is an error, it will be reported at the top of the same page. Correct the error and repeat the test until all errors are resolved.
  7. If the configuration is correct, a Connection successful message will appear on the Create and Deploy page. Click Create and Deploy.
  8. Restart WebLogic Server.

Once you set up a connection pool, you must set up a data source based on that connection pool. The JNDI name you provide for the data source is the name that you will use to set the data-source-jndi-name attribute of the connection tag for the Database control.

To Set Up a Data Source Based on a Connection Pool

  1. Go to the WebLogic Server Console home page by clicking the home page button.
  2. Click Data Sources in the JDBC section of Service Configurations.
  3. Choose Configure a new JDBC data source.
  4. Specify a name in the Name field for this data source.
  5. Specify the JNDI Name that you want to use to refer to this data source.
  6. Clear the Honor Global Transactions check box if necessary. By default this check box is selected, which is the desired setting in nearly all cases. When selected, WebLogic Workshop provides default transaction semantics for web service operations using this data source. These transaction semantics include wrapping database operations that occur within a web service operation in a transaction. If you check this option, you may not attempt to control transaction semantics directly (for example, via calls to java.sql.Connection.setAutoCommit). The sample data source cgSampleDataSource honors global transactions.

    To learn more about WebLogic Workshop's default transaction semantics, see Transactions in WebLogic Workshop.

  7. Select the Emulate Two-Phase Commit for non-XA Driver check box if required. This option is only necessary in a transaction supported setting when the JDBC driver of the to-be-associated connection pool is not XA compliant. Click Continue.
  8. Associate the data source with the connection pool by selecting the pool from the Pool Name drop-down list. Click Continue.
  9. Choose the target server on which you wish to deploy this data source. By default the same server is selected as the associated connection pool. Click Create.
  10. Restart WebLogic Server.

For more information on configuring connection pools and data sources, see Configuring WebLogic JDBC Features.

Related Topics

Database Control

How Do I: Use a Database from a Web Service?

How Do I: WebLogic Workshop-Enable an Existing WebLogic Server Domain?

@jc:connection Annotation