Accessing an existing Java EE data source resource
The same DataSource MBean and JDBCProvider MBean programming model that you use to access a WebSphere® Application Server 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.
About this task
Using the DataSource MBean
JNDI name = java:module/env/jdbc/myDataSource
name = java.module/env/jdbc/myDataSource
WebSphere:type=DataSource,name=java.module/env/jdbc/myDataSource,application=MyApp,module=MyModule,*
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,*
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.
WebSphere:type=DataSource,name=java.comp/env/ds1,application=MyApp,module=MyModule,*
WebSphere:type=DataSource,name=java.comp/env/ds2,application=MyApp,module=MyModule,component=MyBean,*
WebSphere:type=DataSource,name=java.app/env/myDataSource,application=MyApp,*
WebSphere:type=DataSource,name=java.app/env/myDataSource,application=MyOtherApp,*
WebSphere:type=DataSource,application=MyApp,*
Using the JDBCProvider MBean
WebSphere:type=JDBCProvider,name=JDBCProvider_java.module/env/datasource3,application=MyApp,module=MyModule,*
WebSphere:type=DataSource,name=java.module/env/datasource3,application=MyApp,module=MyModule,*