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 data source set up that allows you to access that database.

Each WebLogic Workshop Database control determines which data source it will use from its connection property (@jws:connection tag).

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 Properties pane, expand the connection property.

  3. Click the data-source-jndi-name attribute, then select the value corresponding to the data source you want to use.

To Configure a New Connection Pool and Data Source

To access an Oracle, SQL Server, or Informix database, you first need to install the appropriate JDBC driver. For evaluation versions and installation information, see:

Installing WebLogic jDriver for Microsoft SQL Server

Installing WebLogic jDriver for Oracle

Installing WebLogic jDriver for Informix

Once you have installed the driver, you must configure a new connection pool and data source in WebLogic Server, using the WebLogic Server Console application. If you are running WebLogic Workshop and WebLogic Console on the same computer, you can access the console as follows. 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, both are set to installadministrator.

Next, create a new connection pool:

  1. Navigate to Connection Pools in the JDBC section.

  2. Click Configure a new JDBC Connection Pool.

  3. On the Configuration tab, click General.

  4. Fill in the fields on the General tab as shown in the following table:

    Field

    Description

    Example (using WebLogic jDriver for Microsoft SQL Server)

    Name

    The JNDI name for the connection pool.

    sqlPool

    URL

    The URL for this database. The URL is passed to the driver to create the physical database connections.

     jdbc:weblogic:mssqlserver4v70:sqldbname:1433

    Driver Classname

    The name of the WebLogic jDriver class

    weblogic.jdbc.mssqlserver4v70.Driver

    Properties

    Name-value pairs that provide connection information to the driver

    user=sa

    password=

    db=pubs

    server=sqldbname

    port=1433

    ACL

    Specify the ACL used to control access to this connection pool. By default no ACL is specified, which allows any user open access,  provided that user passes other WebLogic Server security controls.

     

    Password

    Encrypted password for driver to use in accessing database.

     

  5. Apply your changes.

  6. On the Targets tab, choose the target server on which you want to deploy this connection pool.

  7. Apply your changes and restart WebLogic Server.

Once you set up a connection pool, you must set up a data source based on that connection pool. The 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.

WebLogic Workshop provides default transaction semantics for web service operations. The default transaction semantics include wrapping database operations that occur within a web service operation in a transaction. The default transaction semantics require use of a TxDataSource (transacted data source), instead of a DataSource. If you use a Tx Data Source, you may not attempt to control transaction semantics directly (e.g. via calls to java.sql.Connection.setAutoCommit). The sample data source cgSampleDataSource is a Tx Data Source.

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

  1. Depending on whether you want default transaction semantics or not, navigate to Data Sources or Tx Data Sources in the WebLogic Server Console.

  2. Choose Configure a new JDBC data source.

  3. Specify a friendly name in the Name field for this data source.

  4. Specify the JNDI name by which you will refer to this data source.

  5. Specify the name of the pool you created previously in the Pool Name field.

  6. Click the Targets tab and choose the target server on which you wish to deploy this data source.

  7. Restart WebLogic Server.

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

Related Topics

Database Control: Using a Database from Your Web Service

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

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

@jws:connection Tag