What is the standard naming convention of JNDI Name
for a Datasource?
Suppose I have a Datasource named MyAppDS. What is the standard naming convention of JNDI Name
for MyAppDS?
Thanks
What is the standard naming convention of JNDI Name
for a Datasource?
Suppose I have a Datasource named MyAppDS. What is the standard naming convention of JNDI Name
for MyAppDS?
Thanks
The enterprise namespace is rooted in a URL context for the java URL scheme. For example, you might use a name such as "java:comp/env/ejb/Payroll" for Payroll ejb. At the root context of the namespace is a binding with the name "comp", which is bound to a subtree reserved for component-related bindings. The name "comp" is short for component. In the "comp" context, there is binding for "env".The name "env" is bound to a subtree that is reserved for the component's environment-related bindings, as defined by its deployment descriptor. "env" is short for environment. The J2EE recommends (but does not require) the following structure for the "env" namespace.
Resource factory references are placed in subtrees differentiated by their resource manager type. Here are some examples:
"jdbc" for JDBCTM DataSource references "jms" for JMS connection factories "mail" for JavaMail connection factories "url" for URL connection factories
For example, a JDBC Salary database might have the name "java:comp/env/jdbc/Salary".
A resource is a program object that provides connections to systems, such as database
servers and messaging systems. (A Java Database Connectivity resource is sometimes
referred to as a data source.) Each resource object is identified by a unique,
people-friendly name, called the JNDI name. For example, the JNDI name of the
preconfigured JDBC resource for the Java DB database that is shipped with the
GlassFish Server is java:comp/DefaultDataSource. (Java EE official tutorial :Part III Chapter 3.1)
Three JNDI namespaces are used for portable JNDI lookups: java:global, java:module, and java:app. (Java EE official tutorial :Part VII Chapter 32.4.1.1)
By example here is the way Netbeans will call your DB connection in ressource configuration file : jndi-name="jdbc/UrDataSourceName" and the complete jndi name will probably be "java:jdbc/UrDataSourceName"