Network Deployment (Distributed operating systems), v8.0 > Administer applications and their environment > Administer Data access resources > Administer data access applications > Configure a JDBC provider and data source


Access an existing Java EE data source resource

The same DataSource MBean and JDBCProvider MBean programming model that you use to access a WAS managed data source (defined in scripting or the Integrated Solutions Console) can be used to access a Java™ Platform Enterprise Edition (Java EE) data source resource that is defined in the application with the DataSourceDefinition annotation or with the <data-source> element of the deployment descriptor. This feature maintains compatibility with existing scripts, simplifying the management of your resources. This task illustrates through examples how an MBean represents a Java EE data source resource.


Example

Example: Using the DataSource MBean

Use the name field of the DataSource MBean as the JNDI name with special characters, as follows:

JNDI name =  java:module/env/jdbc/myDataSource
name = java.module/env/jdbc/myDataSource

Additional fields for application, module, and component are included whenever applicable; for example:

WebSphere:type=DataSource,name=java.module/env/jdbc/myDataSource,application=MyApp,module=MyModule,*

Use these values, you can query for the MBean for a particular application, as follows:

WebSphere:type=DataSource,name=java.app/env/myDataSource,application=MyApp,*
or query for an identically named java:app JNDI name in a different application as follows:
WebSphere:type=DataSource,name=java.app/env/myDataSource,application=MyOtherApp,*

A query that omits the application field returns both MBeans as follows:

WebSphere:type=DataSource,name=java.app/env/myDataSource,*

In the web module, the Java EE specification defines java:comp to be the same namespace as java:module. Therefore, MBean queries for data sources that are defined in the web module should not include the component field.

To query for java:comp/env/ds1 defined in the web module, use the following:

WebSphere:type=DataSource,name=java.comp/env/ds1,application=MyApp,module=MyModule,*

To query for java:comp/env/ds2 defined in an EJB module, use the following:

WebSphere:type=DataSource,name=java.comp/env/ds2,application=MyApp,module=MyModule,component=MyBean,*

To query for java:app/env/myDataSource defined in an application named MyApp, use the following:

WebSphere:type=DataSource,name=java.app/env/myDataSource,application=MyApp,*

To query for an identically named java:app JNDI name in a different application named MyOtherApp, use the following:

WebSphere:type=DataSource,name=java.app/env/myDataSource,application=MyOtherApp,*

The application, module, and component parameters can also be used to perform a general query for all data sources that are defined in a particular application; for example:

WebSphere:type=DataSource,application=MyApp,*

Example: Using the JDBCProvider MBean

In addition to the DataSource MBean for each Java EE data source, there is also a JDBCProvider MBean. The name of the JDBCProvider MBean is the name of the DataSource MBean prefixed with JDBCProvider_, for example:

WebSphere:type=JDBCProvider,name=JDBCProvider_java.module/env/datasource3,application=MyApp,module=MyModule,*

The JDBCProvider MBean has one data source associated with it, as illustrated in the following example:

WebSphere:type=DataSource,name=java.module/env/datasource3,application=MyApp,module=MyModule,*

Configure a JDBC provider and data source


Related

+

Search Tips   |   Advanced Search