mardi 31 mars 2015

How to bind a JDBC datasource to JNDI context "java:comp/env/jdbc" when not to use web.xml

How to bind a JDBC datasource to JNDI context java:comp/env/jdbc only using code-based approach.


We need to write resource-ref in the web.xml for binding a dataSource to JNDI local context java:comp/env/jdbc. But I want to use only org.springframework.web.context.AbstractContextLoaderInitializer instead of web.xml(the old approach).


We know the method InitialContext#createSubcontext. But some application servers(e.g. Websphere) do not accept to edit the context java:comp/env/jdbc/.


Any solutions?


Versions:



  • Spring 4.0.7

  • Servlet 3.0


Aucun commentaire:

Enregistrer un commentaire