Learn how data source resource definitions are supported in Oracle WebLogic Server Multitenant (MT).
This chapter includes the following sections:
Prior to configuring Java Database Connectivity (JDBC) in a multitenant environment, you must complete certain prerequisite steps.
You must have already created:
A virtual target. See Configuring Virtual Targets.
A domain partition. See Configuring Domain Partitions.
A security realm that is specific to the partition, if necessary. See Configuring Security.
A resource group template, if necessary. See Configuring Resource Group Templates.
A resource group. See Configuring Resource Groups.
This chapter assumes familiarity with existing WebLogic Server data sources. See Administering JDBC Data Sources for Oracle WebLogic Server.
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 one of several 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 be referenced only 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 be referenced only 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
attributes 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 Software-as-a-Service (SaaS) use cases where most template data source settings are common across partitions. If you use override MBeans, then 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, then the override MBean value takes precedence. See Configuring Resource Overrides.
Note:
For any Java EE applications that use JDBC directly, you must update the application to use data sources instead if you want to use JDBC 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 nonpartitioned 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 |
Use a JDBC system resource override or a resource deployment plan. |
Application scoped/packaged data source deployed to a domain or partition |
Use an application deployment plan. |
Standalone data source module deployed to a domain or partition |
Use an 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.
When configuring data sources in a multitenant environment, you should take into consideration several topics, including data source scope, runtime monitoring, security roles and policy definitions, the scope of XA transactions, and more.
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 Oracle WebLogic Server Administration Console and Oracle Enterprise Manager Fusion Middleware Control (FMWC), there is a menu in the first step of the creation process that lists the available scopes in which to create a data source. Using WebLogic Scripting Tool (WLST), it is necessary to create the data source using the createJDBCSystemResource
method on the parent MBean (the MBean for the domain, resource group, or resource group template).
When editing a data source, the data source must reside in the proper scope. There are no additional changes to updating a data source.
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 JDBCPartitionRuntimeMBean
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 prior 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 nonpartition-scoped data source deployments reside under serverRuntime/JDBCServiceRuntime
.
MBeans defined at the domain level are not visible to partition users. If a nondynamic 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 restart the server.
Security roles and policy definitions related to partition data source configuration is the responsibility of the system administrator. 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 information about data source security, see Security for WebLogic Server MBeans and Understanding Data Source Security.
Data source authorization verification is 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 WebLogic Server Administration Console (they are not supported in Fusion Middleware Control).
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 they are managed independently.
For more information about transaction configuration and restrictions, see Configuring Transactions.
A data source that is associated with a partition is started during a partition start and shut down 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.
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. See Configuring Partition-Scoped Diagnostic Image Capture.
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 about logging, see Monitoring and Debugging Partitions.
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 the reverse. 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.
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.
This sample WLST program shows how to configure 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 data source ds-in-template in rgt" createJDBCSystemResource(owner=rgtBean, resourceName='ds-in-template') activate() startEdit() print "Creating data source ds-using-template in rg using rgt" createJDBCSystemResource(owner=partition1rgitMBean, resourceName='ds-using-template') activate() startEdit() print "Creating override for data source ds-in-template" createJDBCSystemResourceOverride(partition1MBean, 'ds-in-template', jdbc:oracle:thin:@dbhost:1521/otrade2', 'scott', 'tiger',1,10,50) activate() startEdit() print "Creating data source ds in partition1-rg" createJDBCSystemResource(owner=partitionrgMBean, resourceName='ds') activate() # You cannot create a data source directly in a partition. # createJDBCSystemResource(owner=partition1MBean, resourceName='ds') startEdit() print "Creating data source 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) def createJDBCSystemResourceOverride(partition, dsname, url, user, password, initialCapacity, minCapacity, maxCapacity): oMBean=partition.createJDBCSystemResourceOverride(dsname) oMBean.setDataSourceName(dsname) oMBean.setURL(url) oMBean.setUser(user) oMBean.setPassword(password) oMBean.setInitialCapacity(initialCapacity) oMBean.setMinCapacity(minCapacity) oMBean.setMaxCapacity(maxCapacity)
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
Note:
When you create a data source in a resource group template, values, such as URL and user, may be overridden in the resource group. Since this is an expected use case, it is handled in a special manner by the Administration Console. If you do not fill in a value, it will be filled in with a placeholder value based on the attribute name.
To configure JDBC data sources:
To monitor data sources at various levels:
To produce a partition-scoped diagnostics image:
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
To configure partition-scoped deployments:
As with nonpartition scoped deployments, from the home page, 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 the associated link in the console. Initially there is no deployment plan.
To create an application deployment plan, Oracle recommends using the WebLogic Server Administration Console which will create the plan for you:
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>
If you want to override attributes of a resource group template-derived partition data source other than the user, password, or URL values, then you will need to create a resource deployment plan. 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 partition's Configuration > General page.
You can use Fusion Middleware Control to configure JDBC overrides in a manner similar to using the WebLogic Server Administration Console but with a different user interface and navigation paths. However, you must use the WebLogic Server Administration Console to configure data source security because it is not currently available in Fusion Middleware Control.
From the WebLogic Domain 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 its name.
To create a new data source, click Create and select the type of data source that you want to create.
On the Data Source Properties page, use the Scope menu to specify the data source scope.
From the WebLogic Domain menu, select Environments > Domain Partitions.
Click a partition name to edit the partition attributes.
To create JDBC system resource overrides:
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 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
The following references provide additional information on WebLogic Server JDBC data sources, configuring data sources using the Oracle WebLogic Server Administration Console, and an example of configuring JDBC system resources using REST.
WebLogic Server JDBC Data Sources in Administering Oracle WebLogic Server with Fusion Middleware Control.
Configure Data Sources in Oracle WebLogic Server Administration Console Online Help.
Configuring System Resources and Creating Partition-Scoped System Resources in Administering Oracle WebLogic Server with RESTful Management Services.