I've noticed that both ways of looking up a DataSource
using JNDI work:
With the added bonus that the first one doesn't seem to anger Websphere when used from an unmanaged thread ( started by Quartz ).
Are there any pitfalls from accessing JNDI objects without the prefix?
java:comp/env is the node in the JNDI tree where you can find properties for the current Java EE component (a webapp, or an EJB). Context envContext = (Context)initContext.lookup("java:comp/env");
In the property file you have all properties declared with a prefix – spring. datasource . Therefore using Spring Boot it is very easy to load properties in Java class attributes. Simply specify the prefix using @ConfigurationProperties annotation and add the same property names as class attributes.
2. JNDI Description. Any work with JNDI requires an understanding of the underlying service as well as an accessible implementation. For example, a database connection service calls for specific properties and exception handling. However, JNDI's abstraction decouples the connection configuration from the application.
This should be OK, since java:comp/env
is the global JNDI namespace.
It may depend on the application server where such configurations also appear in the JNDI tree.
Locate your JDBC DataSource in WebSphere Application Server using JNDI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With