15 Configuring JDBC

This chapter describes how data source resource definitions are supported in WebLogic Server Multitenant (MT).

Prior to configuring JDBC in a multitenant environment, it is assumed that you have already created:

This chapter assumes familiarity with existing WebLogic Server data sources. For more information, see Administering JDBC Data Sources for Oracle WebLogic Server.

This chapter includes the following sections:

About Supported Data Source Types

When working in a non-multitenant WebLogic Server environment, a data source may be defined as a system resource or deployed at the domain level. When using WebLogic Server MT in a multitenant environment, a data source may also be defined in the following scopes:

  • As part of a resource group that is created at the domain level. The referenced data source must be qualified with the appropriate database credentials, URL, driver properties, and attributes for the domain-level scope. A data source referenced by a resource group at the domain level is a global system resource. A data source module descriptor may only be referenced by a single domain-level resource group.

  • As part of a resource group that is created at the partition level. The referenced data source must be qualified with the appropriate database credentials, URL, driver properties, and attributes for the partition. A data source descriptor can only be referenced by a single resource group in a partition.

  • As part of a resource group template that is created at the domain level. Such definitions are considered a template data source definition that is fully qualified by individual partitions that reference the resource group template.

  • As part of a resource group at the partition level that is based on a resource group template. Because template resource descriptors referenced by a resource group template may be incomplete, by lacking or having an incorrect URL, credentials, or both, the resources defined by each resource group need to have the appropriate overrides specified for deployment to the partition runtime.

    You can use a JDBCSystemResourceOverrideMBean to override the user, password, and URL for a resource group based on a resource group template that is defined at the partition level. These three attributes represent data source settings that would typically be qualified on a per-partition basis for SaaS use cases where most template data source settings are common across partitions. If you use override MBeans, you must define a separate override MBean for each data source referenced by the resource group. Configuration changes to these attributes that are made at runtime (post data source deployment) require that the partition data source be restarted for the changes to take effect. A resource deployment plan may be specified for a resource group that allows overriding arbitrary attributes of any data source descriptor referenced by the resource group. The single deployment plan is defined in an external file whose path is specified in the partition configuration and applies to all data sources in the partition. The resource deployment plan is processed before applying override attributes to the resource group-referenced data source. If a given data source attribute is specified in both a resource deployment plan and an override MBean, the override MBean value takes precedence. For more information, see Configuring Resource Overrides.

  • As part of a deployed object at the partition-level. This includes a packaged data source in an EAR or WAR file, in a standalone data source module, or a Java EE data source definition defined in a Java annotation or a descriptor file in an application. Each of these objects can be deployed to a partition. Packaged and standalone data sources can be updated using application deployment plans, the same as the corresponding non-partitioned data sources. There is no override mechanism for Java EE data source definitions.

To summarize, the data source component supports the following data source deployment types.

Data Source Deployment Type Parameter Override Support
Domain-level system resource, optionally scoped in a resource group No override support; change the data source directly.
Resource group template system resource Change the data source directly or override in the resource group derived from the resource group template.
Partition-level system resource in a resource group No override support; change the data source directly.
Partition-level system resource in a resource group based on a resource group template JDBC system resource override or resource deployment plan.
Application scoped/packaged data source deployed to a domain or partition Application deployment plan.
Standalone data source module deployed to a domain or partition Application deployment plan.
Data source definitions (Java EE 6) deployed to a domain or partition No override support.

The domain structure related to data sources is as follows:

  • Domain

    • Data source with global scope

    • Domain-level resource group with data source with global scope

    • Domain-level resource group template with data source

    • Partition

      • Partition-level resource group with data source

      • Partition-level resource group based on resource group template

      • Partition-level JDBC system resource override

      • Partition-level resource deployment plan

      • Object deployed at the partition level

The resource group template references system resource definitions such as data source module descriptors. The partition defines one or more resource groups that may reference a system resource definition directly, a resource group template, or both.

Configuring JDBC Data Sources: Related Considerations

The following sections describe considerations when configuring data sources in a multitenant environment.

Data Source Scope

Creating a data source that is scoped to a domain-level resource group or in a partition is similar to creating a domain-level system resource. The only additional step is to specify the scope. In the WLS Administration Console and Fusion Middleware Control (FMWC), there is a drop-down menu in the first step of the creation process that lists the available scopes in which to create a data source. In WLST, it is necessary to create the data source using createJDBCSystemResource on the owner MBean (the MBean for the domain, resource group, or resource group template).

When editing a data source, the data source must be looked up in the proper scope. There are no additional changes to updating a data source.

Runtime Monitoring

The existing data source runtime MBeans are supported for partition-scoped data source deployments and are accessible to JMX-based management clients. The runtime MBean type depends on the data source type deployed. For example, a generic data source is represented by a JDBCDataSourceRuntimeMBean type.

The DataSourceRuntimeMBean created for a partition-scoped data source deployment is parented by the JDBCPartitionRuntime MBean of the partition and provides statistics and runtime operations that are specific to the partition's data source instance.

Partition-scoped data source runtime MBeans have a name attribute similar to the following:

com.bea:ServerRuntime=myserver,Name=ds,Type=JDBCDataSourceRuntime, JDBCPartitionRuntime=Partition1,PartitionRuntime=Partition1 

The parent attribute is set to:

com.bea:ServerRuntime=myserver,Name=Partition1,Type=JDBCPartitionRuntime

Note that in the above example the partition-scoped data source name is "ds", the partition name is "Partition1" and the server name is "myserver".

The data source runtime MBeans reside in the runtime MBean hierarchy under serverRuntime/PartitionRuntimes/partition/JDBCPartitionRuntime. Whereas the runtime MBeans for non-partition-scoped data source deployments reside under serverRuntime/JDBCServiceRuntime.

MBeans defined at the domain level are not visible to partition users. If a non-dynamic parameter is updated in a partition, the change does not take effect immediately but occurs the next time that the data source in the partition is restarted or the partition itself is restarted. It is not necessary to re-start the server.

Security

Security roles and policy definitions related to partition data source configuration is the responsibility of the system administrator. For more information, see Configuring Security. It is optional to configure a security realm that is specific to the partition. Otherwise, configuring security for a partition-scoped data source is similar to a global data source. For more detailed information on data source security, see "Security for WebLogic Server MBeans" and "Understanding Data Source Security".

Data source authorization checks are supported for partition-scoped deployments using the partition-specific security realm where applicable.

There is support for defining credential mapper entries for use with data source security features for partition-scoped deployments. Data source credential mapper entries are used with data source security options: identity-based pooling, Set Client Identifier, and proxy authentication. Credential mapper entries should be created in the WLS Administration Console (they are not supported in FMWC).

Transactions Scope

The scope of XA transactions are at the domain level and span access to partition-level resources. Partition-scoped resource names are qualified with the partition name so that resources are unique to the transaction manager and managed independently.

For more information on transaction configuration and restrictions, see Configuring Transactions.

Partition Life Cycle

A data source that is associated with a partition is started during a partition start and shutdown during a partition shutdown or forced shutdown. Partition start and shutdown can be performed by the WebLogic Server system administrator and operator, the partition administrator, and the partition operator.

Diagnostic Image Source

You can limit the scope of a diagnostic image to a partition. For diagnostic image capture requests that specify a partition, the data source output is restricted to that of data sources that are scoped to the target partition. For more information, see Configuring Partition Scope Diagnostic Image Capture.

Logging

Partition-scoped data source log messages are qualified with the partition ID and name when the domain log format is not configured for backward compatibility with pre-12.2.1 logging. For more information on logging, see Monitoring and Debugging Partitions.

JNDI Bindings

A data source is bound into the appropriate JNDI context at deployment time under the name or names specified in the data source module descriptor.

Data Source Scope JNDI Namespace
Application Application
Partition resource group Partition
Domain resource group Global

Note that a data source instance obtained from a JNDI namespace preserves its scope even if accessed under a different partition context.

Cross-partition access occurs when an application running in one partition accesses a resource in another partition. This also applies to partition level access to the domain level and vice versa. Cross partition data source access occurs when an application running in one partition performs a JNDI lookup of a data source defined in another partition by using either the partition URL, or the ”domain:” or ”partition:” syntax. In WebLogic Server 12.2.1, this causes a warning to be generated in the log so that applications know that a change is required.

Deprecated Drivers Not Supported

The three WebLogic Server driver types that are registered under the JDBC URL prefix jdbc:weblogic:pool, jdbc:weblogic:rmi, and jdbc:weblogic:jts are deprecated and are not supported with partition-scoped data sources. Existing JDBC client logic that specifies the connectionPoolID property with the data source name, does not fail to find the data source in a partition. Applications that use the pool, JTS, or RMI drivers must modify their configurations to specify data source JNDI names instead to work in a partition configuration.

Related to this, an EJB RDBMS Bean descriptor cannot use <pool-name> to access a partition-scoped data source in a JDBC session. Using a JNDI name is supported in this situation.

Configuring JDBC Data Sources: WLST Example

The following is a sample WLST program that shows using a WebLogic Server data source in an multitenant environment. It creates two virtual targets, one for the domain and one for the partition. It creates one partition. It then creates a resource group, a resource group template, and a resource group based on the resource group template in the partition. It then creates the same data source in four scopes:

  • Resource group template

  • Resource group using the resource group template and a system override

  • Resource group

  • Domain

Last, it starts the partition.

import sys, socket
import os
hostname = socket.gethostname()
partition='partition1'
connect("weblogic","welcome1","t3://"+hostname+":7001")
edit()
startEdit()
serverBean = getMBean('/Servers/myserver')
realmBean=cmo.getSecurityConfiguration().getDefaultRealm()
pB = cmo.lookupPartition(partition)
if pB != None:
   print "[ERROR] Partition with Name '%s' already exits" % partition
   cancelEdit('y')
   exit('y')
host='%s.us.company.com' %hostname
def createVirtualTarget(name, host, domain, target, prefix):
    print "Creating virtual target " + name
    domain=getMBean('/')
    vt=domain.createVirtualTarget(name)
    vt.addTarget(target)
    vt.setHostNames(jarray.array([String(host)],String))
    vt.setUriPrefix(prefix)
    return vt
def createJDBCSystemResource(owner, resourceName):
    systemResource=owner.createJDBCSystemResource(resourceName)
    systemResource.setName(resourceName)
    jdbcResource=systemResource.getJDBCResource()
    jdbcResource.setName(resourceName)
    driverParams=jdbcResource.getJDBCDriverParams()
    driverParams.setDriverName('oracle.jdbc.OracleDriver')
    driverParams.setUrl('jdbc:oracle:thin:@dbhost:1521/otrade')
#    driverParams.setDriverName('org.apache.derby.jdbc.EmbeddedDriver')
#    driverParams.setUrl('jdbc:derby:memory:mydb\;create=true')
    properties = driverParams.getProperties()
    properties.createProperty('user', 'dbuser')
    driverParams.setPassword('MYPASSWD')
    jdbcDataSourceParams=jdbcResource.getJDBCDataSourceParams()
    jdbcDataSourceParams.addJNDIName(resourceName)
    jdbcDataSourceParams.setGlobalTransactionsProtocol('None')
    return systemResource
def createJDBCSystemResourceOverride(partition, dsname, url, user, password):
   oMBean=partition.createJDBCSystemResourceOverride(dsname)
   oMBean.setURL(url)
   oMBean.setUser(user)
   oMBean.setPassword(password)
vtname='partition1'
vtBean=createVirtualTarget(vtname+'-vtarget', host, getMBean('/'),
  getMBean('/Servers/myserver'), '/' + vtname)
vtname='domain'
vtBean1=createVirtualTarget(vtname+'-vtarget', host, getMBean('/'),
  getMBean('/Servers/myserver'), '/' + vtname)
print 'Creating partition partition1'
domain = getMBean("/")
partition1MBean=domain.createPartition('partition1')
partition1MBean.addDefaultTarget(vtBean)
partition1MBean.setRealm(realmBean)
partition1MBean.addAvailableTarget(vtBean)
print 'Creating resource group template rgt'
rgtBean=cmo.createResourceGroupTemplate('rgt')
print 'Creating resource group partition1-rg in partition1'
partitionrgMBean=partition1MBean.createResourceGroup('partition1-rg')
partitionrgMBean.addTarget(vtBean)
print 'Creating resource group partition1-rg-with-template in partition1'
partition1rgitMBean=partition1MBean.createResourceGroup('partition1-rg-with-template')
partition1rgitMBean.setResourceGroupTemplate(getMBean('/ResourceGroupTemplates/rgt'))
print 'Creating domain resource group global-rg'
cd('/')
cmo.createResourceGroup('global-rg')
cd("/ResourceGroups/global-rg")
cmo.addTarget(vtBean1)
save()
activate()
# Create 4 data sources
startEdit()
print "Creating datasource ds-in-template in rgt"
createJDBCSystemResource(owner=rgtBean, resourceName='ds-in-template')
activate()
startEdit()
print "Creating datasource ds-using-template in rg using rgt"
createJDBCSystemResource(owner=partition1rgitMBean, resourceName='ds-using-template')
activate()
startEdit()
print "Creating override for datasource ds-in-template"
createJDBCSystemResourceOverride(partition1MBean, 'ds-in-template',   
     jdbc:oracle:thin:@dbhost:1521/otrade2', 'scott', 'tiger')
activate()
startEdit()
print "Creating datasource ds in partition1-rg"
createJDBCSystemResource(owner=partitionrgMBean, resourceName='ds')
activate()
# You cannot creating datasource directly in partition
# createJDBCSystemResource(owner=partition1MBean, resourceName='ds')
startEdit()
print "Creating datasource ds in domain"
createJDBCSystemResource(owner=domain, resourceName='ds')
cd('/SystemResources/' + "ds" )
set('Targets',jarray.array([ObjectName('com.bea:Name=' + 'AdminServer' + ',Type=Server')], ObjectName))
save()
activate()
startPartitionWait(partition1MBean)

Note that the createJDBCSystemResource method is unusual in that it does not have many different parameters to create the data source. Instead, the same parameters are used each time.

The following sample WLST output shows a global system resource data source deployment under the server runtime and the three partition-scoped data source deployments under the partition runtime.

> ls('JDBCSystemResources')
dr--   ds
> ls('Partitions')
drw-   partition1
> serverRuntime()
> ls('JDBCServiceRuntime/AdminServer/JDBCDataSourceRuntimeMBeans')
dr--   ds
> ls(
''PartitionRuntimes/partition1/JDBCPartitionRuntime/partition1/JDBCDataSourceRuntimeMBeans')
dr--   ds
dr--   ds-in-template
dr--   ds-using-template

Configuring JDBC Data Sources: WLS Administration Console Example

The following sections show the results of the Configuring JDBC Data Sources: WLST Example in the WLS Administration Console.

Configuring JDBC Data Sources

From the WLS Administration Console Home page, select Data Sources to display a summary table which lists all the system resource data sources that are configured in all scopes (domain, resource group templates, and resource groups). The table displays the scope and partition name where applicable.

Click on the name of a data source. The Configuration > General page displays the configuration attributes unaffected by any existing JDBC system resource overrides. The overrides do not appear at this level.

Select Security > Credential Mappings and click New. Enter the WLS User, Remote User, and Remote Password values for credential mappings associated with the data source.

On the data sources summary page, click New and select Generic Data Source. From the Scope drop-down menu, you can specify a global data source or whether to create the data source in an existing resource group template or resource group (the names of all the available scopes appears in the drop-down menu).

From the WLS Administration Console Home page, select Domain Partitions to display the domain partitions summary table which lists all the configured partitions. The information for each partition will include the nested resource groups, the default targets, and the state.

To configure a specific partition, click on its name. Select Resource Overrides > JDBC System to display a summary table which lists the existing JDBC overrides. To create a new JDBC system resource override, click New. The Data Source drop-down menu lists the available data sources for creating the override. The WLS Administration Console lists the data sources from all the resource groups in the partition, however, only resource groups derived from resource group templates would need an override. Non-derived resource groups can be updated directly; overriding them is not recommended. For each existing override, the table displays the name of the override, the data source, and the URL. Clicking on the override name displays a configuration page where you can update any of the override values (URL, user, or password).

Monitoring JDBC Data Sources

You can monitor data sources at various levels. On the domain level, from the Home page, select Data Sources > Monitoring to view all running data sources in all scopes.

On the partition level, select Domain Partitions and click on a specific partition name. Select Resource Groups, click on a specific resource group name, then select Services > JDBC to view the data sources defined in this scope.

JDBC Data Source Diagnostics

To produce a partition-scoped diagnostics image, from the Home page, select Diagnostics Images. Click on the plus sign (+) for the desired server to expand the list. Select the radio button for a specific partition name and then click Capture Image. The Diagnostic Image Properties page specifies the Destination Directory location for the image ZIP file. Open the ZIP file to view a JDBC.txt file that might look like the following sample. Note that resource names are decorated with $partitionname.

Dumping Resource Pool:ds-in-template$partition1
Resource Pool:ds-in-template$partition1:dumpPool Current Capacity = 1
Resource Pool:ds-in-template$partition1:dumpPool dumping available resources, #entries = 1
Resource Pool:ds-in-template$partition1:dumpPool available[0] = autoCommit=true,enabled=true,isXA=false,isJTS=false,vendorID=100,connUsed=false,doInit=false,'null',destroyed=false,poolname=ds-in-template$partition1,appname=null,moduleName=null,connectTime=862,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=0,secondsToTrustAnIdlePoolConnection=10,currentUser=null,currentThread=null,lastUser=null,currentError=null,currentErrorTimestamp=null,JDBC4Runtime=true,supportStatementPoolable=true,needRestoreClientInfo=false,defaultClientInfo={},supportIsValid=true
Resource Pool:ds-in-template$partition1:dumpPool dumping reserved resources, #entries = 0
Resource Pool:ds-in-template$partition1:dumpPool # dead resources = 0
Dumping Resource Pool: ds-in-template$partition1 complete
Dumping Resource Pool:ds$partition1
Resource Pool:ds$partition1:dumpPool Current Capacity = 1
Resource Pool:ds$partition1:dumpPool dumping available resources, #entries = 1
Resource Pool:ds$partition1:dumpPool available[0] = autoCommit=true,enabled=true,isXA=false,isJTS=false,vendorID=100,connUsed=false,doInit=false,'null',destroyed=false,poolname=ds$partition1,appname=null,moduleName=null,connectTime=1277,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=0,secondsToTrustAnIdlePoolConnection=10,currentUser=null,currentThread=null,lastUser=null,currentError=null,currentErrorTimestamp=null,JDBC4Runtime=true,supportStatementPoolable=true,needRestoreClientInfo=false,defaultClientInfo={},supportIsValid=true
Resource Pool:ds$partition1:dumpPool dumping reserved resources, #entries = 0
Resource Pool:ds$partition1:dumpPool # dead resources = 0
Dumping Resource Pool: ds$partition1 complete
Dumping Resource Pool:ds-using-template$partition1
Resource Pool:ds-using-template$partition1:dumpPool Current Capacity = 1
Resource Pool:ds-using-template$partition1:dumpPool dumping available resources, #entries = 1
Resource Pool:ds-using-template$partition1:dumpPool available[0] = autoCommit=true,enabled=true,isXA=false,isJTS=false,vendorID=100,connUsed=false,doInit=false,'null',destroyed=false,poolname=ds-using-template$partition1,appname=null,moduleName=null,connectTime=467,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=0,secondsToTrustAnIdlePoolConnection=10,currentUser=null,currentThread=null,lastUser=null,currentError=null,currentErrorTimestamp=null,JDBC4Runtime=true,supportStatementPoolable=true,needRestoreClientInfo=false,defaultClientInfo={},supportIsValid=true
Resource Pool:ds-using-template$partition1:dumpPool dumping reserved resources, #entries = 0
Resource Pool:ds-using-template$partition1:dumpPool # dead resources = 0
Dumping Resource Pool: ds-using-template$partition1 complete

Partition-Scoped Deployments

As with non-partition scoped deployments, from the Home page, you select Deployments, click Install and then locate the EAR or WAR file that you want to deploy. On the first page of the Install Application Assistant, for deployment scope, you can select either the global scope or one of the existing resource group templates or resource groups.

After deploying the EAR or WAR file, you can view the associated modules and scope by clicking on the associated link in the console. Initially there is no deployment plan. To create an application deployment plan Oracle recommends using the WLS Administration Console which will create it for you. Select the deployed data source, change the configuration, and save the changes. The console creates the associated deployment plan and specifies the deployment plan name. The following is a sample application deployment plan.

<?xml version='1.0' encoding='UTF-8'?> 
<deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd">
  <application-name>ds-jdbc.xml</application-name>
  <variable-definition>
    <variable>
      <name>JDBCConnectionPoolParams_InitialCapacity_14417323945070</name>
      <value>1</value>
    </variable>
    <variable>
       <name>JDBCConnectionPoolParams_MinCapacity_14417323945071</name>
      <value>1</value>
    </variable>
    <variable>
      <name>JDBCConnectionPoolParams_StatementCacheSize_14417323945072</name>
      <value>10</value>
    </variable>
    <variable>
      <name>JDBCConnectionPoolParams_MaxCapacity_14417323945073</name>
      <value>20</value>
    </variable>
    <variable>
      <name>JDBCConnectionPoolParams_StatementCacheType_14417323945074</name>
      <value>LRU</value>
    </variable>
  </variable-definition>
  <module-override>
    <module-name>ds-jdbc.xml</module-name>
    <module-type>jdbc</module-type>
    <module-descriptor external="false">
      <root-element>jdbc-data-source</root-element> 
      <uri>.</uri>
      <variable-assignment>
        <name>JDBCConnectionPoolParams_InitialCapacity_14417323945070</name>
        <xpath>/jdbc-data-source/jdbc-connection-pool-params/initial-capacity</xpath>
      </variable-assignment>
      <variable-assignment>
        <name>JDBCConnectionPoolParams_MinCapacity_14417323945071</name>
        <xpath>/jdbc-data-source/jdbc-connection-pool-params/min-capacity</xpath>
      </variable-assignment>
      <variable-assignment>
        <name>JDBCConnectionPoolParams_StatementCacheSize_14417323945072</name>
        <xpath>/jdbc-data-source/jdbc-connection-pool-params/statement-cache-size</xpath>
      </variable-assignment>
      <variable-assignment>
        <name>JDBCConnectionPoolParams_MaxCapacity_14417323945073</name>
        <xpath>/jdbc-data-source/jdbc-connection-pool-params/max-capacity</xpath>
      </variable-assignment>
      <variable-assignment>
        <name>JDBCConnectionPoolParams_StatementCacheType_14417323945074</name>
        <xpath>/jdbc-data-source/jdbc-connection-pool-params/statement-cache-type</xpath>
      </variable-assignment>
    </module-descriptor>
  </module-override>
  <config-root>D:\tmp1221\partition1\ds-jdbc.xml\app\plan</config-root>
</deployment-plan>

Resource Deployment Plan

If you want to override attributes of a resource group template-derived partition data source other than the user, password, or URL values, you will need to create a resource deployment plan. For more information, see Configuring Resource Deployment Plans: Main Steps and WLST Example.

The following is a sample resource deployment plan. Note that the descriptor-file-path, resource-type, and the resource name elements are used to identify where the descriptor resides.

<resource-deployment-plan
 xmlns="http://xmlns.oracle.com/weblogic/resource-deployment-plan"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://xmlns.oracle.com/weblogic/resource-deployment-plan
 http://xmlns.oracle.com/weblogic/resource-deployment-plan/1.0/resource-deployment-plan.xsd">
  <variable-definition>
    <variable>
      <name>JDBCConnectionPoolParams_InitialCapacity_14423700625350</name>
      <value>2</value>
    </variable>
    <variable>
      <name>JDBCConnectionPoolParams_MinCapacity_14423700625511</name>
      <value>5</value>
    </variable>
    <variable>
      <name>JDBCConnectionPoolParams_StatementCacheSize_14423700625512</name>
      <value>10</value>
    </variable>
    <variable>
      <name>JDBCConnectionPoolParams_StatementCacheType_14423700625513</name>
      <value>LRU</value>
    </variable>
  </variable-definition>
  <external-resource-override>
    <resource-name>ds-in-template</resource-name>
    <resource-type>jdbc-system-resource</resource-type>
    <root-element>jdbc-data-source</root-element>
    <descriptor-file-path>resource-group-templates/rgt/jdbc</descriptor-file-path>
    <variable-assignment>
      <name>JDBCConnectionPoolParams_InitialCapacity_14423700625350</name>
      <xpath>/jdbc-data-source/jdbc-connection-pool-params/initial-capacity</xpath>
    </variable-assignment>
    <variable-assignment>
      <name>JDBCConnectionPoolParams_MinCapacity_14423700625511</name>
      <xpath>/jdbc-data-source/jdbc-connection-pool-params/min-capacity</xpath>
    </variable-assignment>
    <variable-assignment>
      <name>JDBCConnectionPoolParams_StatementCacheSize_14423700625512</name>
      <xpath>/jdbc-data-source/jdbc-connection-pool-params/statement-cache-size</xpath>
    </variable-assignment>
    <variable-assignment>
      <name>JDBCConnectionPoolParams_StatementCacheType_14423700625513</name>
      <xpath>/jdbc-data-source/jdbc-connection-pool-params/statement-cache-type</xpath>
    </variable-assignment>
  </external-resource-override>
</resource-deployment-plan> 

To associate the resource deployment plan with a partition, provide the path to the resource deployment plan on the on the partition's Configuration > General page.

Configuring JDBC Data Sources: Fusion Middleware Control Example

You can use Fusion Middleware Control (FMWC) to configure JDBC overrides in a manner similar to using the WLS Administration Console but with a different user interface and navigation paths. However, you must use the WLS Administration Console to configure data source security since it is not currently available in FMWC.

From the WebLogic Domain drop-down menu, select JDBC Data Sources to display a list of existing data sources with their associated type, scope, and if applicable, resource group, resource group template and partition names.

To edit an existing data source, click on its name.

To create a new data source, click Create and select the type of data source you want to create. On the Data Source Properties page, use the Scope drop-down menu to specify the data source scope.

From the WebLogic Domain drop-down menu, select Environments > Domain Partitions and click on a partition name to edit the partition attributes.

To create JDBC system resource overrides, click on the partition name. From the left-side Domain Partition drop-down menu, select Administration > Resource Overrides. Use this page to view every resource group that is derived from a resource group template along with the resource type and the name of the resource group template. If there is no existing override, the Has Overrides column will be blank. Click the Edit Overrides icon to create an override. If the Has Overrides column has a check mark in it, click the Edit Overrides icon to update the existing overrides.

Configuring JDBC Data Sources: REST Example

All of the JDBC configuration and runtime information is available using REST. For more information, see Administering Oracle WebLogic Server with RESTful Management Services.

This is an example that gets all of the data sources in the partition, partition1.

curl --user weblogic:welcome1 -H X-Requested-By:MyClient \
  -H Accept:application/json \
  -H Content-Type:application/json -X GET \
  http://host:7001/management/weblogic/latest/serverRuntime/\
partitionRuntimes/partition1/JDBCPartitionRuntime/JDBCDataSourceRuntimeMBeans

The following is an abbreviated output:

{
...
    "items": [
        {
....
            "identity": [
                "partitionRuntimes",
                "partition1",
                "JDBCPartitionRuntime",
                "JDBCDataSourceRuntimeMBeans",
                "ds-in-template"
            ],
            "connectionsTotalCount": 1,
...
        },
        {
...
            "identity": [
                "partitionRuntimes",
                "partition1",
                "JDBCPartitionRuntime",
                "JDBCDataSourceRuntimeMBeans",
                "ds-using-template"
            ],
...
        },
        {
...
            "identity": [
                "partitionRuntimes",
                "partition1",
                "JDBCPartitionRuntime",
                "JDBCDataSourceRuntimeMBeans",
                "ds"
            ],
            "connectionsTotalCount": 1,
...
        }
    ]
}

The following shell script creates a new data source, ds3, in a resource group, partition1-rg, in a partition, partition1, using REST.

host=myhost
cmd="curl --user weblogic:welcome1 \
  -H X-Requested-By:MyClient \
  -H Accept:application/json \
  -H Content-Type:application/json "
echo "Start a config txn"
${cmd} -d '{}' \
-X POST \
 http://${host}:7001/management/weblogic/latest/edit/changeManager/startEdit
 
echo "\nCreate the JDBCSystemResource - note - can't save the changes yet"
echo "because we still need to set its JDBCResource's name too."
${cmd} -d "{
      name: 'ds3'
   }" -X POST \
   http://${host}:7001/management/weblogic/\
latest/edit/partitions/partition1/\
resourceGroups/partition1-rg/JDBCSystemResources?saveChanges=false
echo "\nSet the JDBCSystemResource's JDBCResource's name and let the changes be"
echo "saved automatically."
${cmd} -d "{
     name: 'ds3'
  }" -X POST \
  http://${host}:7001/management/weblogic/latest/\
edit/partitions/partition1/resourceGroups/partition1-rg/\
JDBCSystemResources/ds3/JDBCResource
echo "\nSet the Data Source Params"
${cmd} -d "{
    globalTransactionsProtocol: 'EmulateTwoPhaseCommit',
    JNDINames: [ 'ds3' ] 
  }" -X POST \
  http://${host}:7001/management/weblogic/latest/\
edit/partitions/partition1/resourceGroups/partition1-rg/\
JDBCSystemResources/ds3/JDBCResource/JDBCDataSourceParams
echo "\nSet the Driver Params"
${cmd} -d "{
    driverName: 'oracle.jdbc.OracleDriver',
    password: 'MYPASSWD',
    url: 'jdbc:oracle:thin:@dbhost:1521/otrade'
  }" -X POST \
  http://${host}:7001/management/weblogic/latest/\
edit/partitions/partition1/resourceGroups/partition1-rg/\
JDBCSystemResources/ds3/JDBCResource/JDBCDriverParams
echo "\nSet the Properties Params"
${cmd} -d "{
    value: 'dbuser',
    name: 'user'
  }" -X POST \
  http://${host}:7001/management/weblogic/latest/\
edit/partitions/partition1/resourceGroups/partition1-rg/\
JDBCSystemResources/ds3/JDBCResource/JDBCDriverParams/properties/properties
echo "\nActivate the changes"
${cmd} -d '{}' \
-X POST \
 http://${host}:7001/management/weblogic/latest/edit/changeManager/activate

Configuring JDBC Data Sources: Related Tasks and Links

For additional information, see the following: