java - Tomcat JNDI resource name aliases -
java - Tomcat JNDI resource name aliases -
is possible create jndi tomcat resource multiple names (synonyms, aliases)? like
<resource name="jdbc/product-ds" alias="jdbc/product-cfg-ds" type="com.mchange.v2.c3p0.combopooleddatasource" ... />
i need this, because there 2 modules utilize same datasource, different jndi name. simplest solution sync names, unfortunately it's not possible @ moment.
you can this. took me while work out right sequence. need define jdbc/product-ds in server.xml (tomcat/conf/server.xml) in globalnamingresources section kind of this:
<globalnamingresources> <resource name="jdbc/product-ds " auth="container" type="javax.sql.datasource" driverclassname="oracle.jdbc.oracledriver" url="jdbc:oracle:thin:@127.0.0.1:1521:mysid" username="scott" password="tiger" maxactive="20" maxidle="10" maxwait="-1"/> </globalnamingresources>
then can rename in server context.xml (tomcat/conf/context.xml)
like this:
<resourcelink name="jdbc/product-cfg-ds" global="jdbc/product-ds" type="javax.sql.datasource"/>
the global name renamed applications deployed on the server. don't think global jdbc/product-ds available in application, if did want you'd need add:
<resourcelink name="jdbc/product-ds" global="jdbc/product-ds" type="javax.sql.datasource"/>
java tomcat datasource jndi
Comments
Post a Comment