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
In Design View, click the Database control your service will use to access the database.
In the Properties pane, expand the connection property.
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.
Launch the console by navigating to http://localhost:7001/console/.
Provide your user name and password; by default, both are set to installadministrator.
Next, create a new connection pool:
Navigate to Connection Pools in the JDBC section.
Click Configure a new JDBC Connection Pool.
On the Configuration tab, click General.
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. |
|
Apply your changes.
On the Targets tab, choose the target server on which you want to deploy this connection pool.
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.
Depending on whether you want default transaction semantics or not, navigate to Data Sources or Tx Data Sources in the WebLogic Server Console.
Choose Configure a new JDBC data source.
Specify a friendly name in the Name field for this data source.
Specify the JNDI name by which you will refer to this data source.
Specify the name of the pool you created previously in the Pool Name field.
Click the Targets tab and choose the target server on which you wish to deploy this data source.
Restart WebLogic Server.
For more information on configuring connection pools and data sources, see Configuring WebLogic JDBC Features.
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?