应用服务器配置JNDI
web.xml配置
在web.xml里面添加下面的配置
<resource-ref id="ResourceRef_123">
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
JBOSS程序配置
需要在web.xml配置的基础上增加一文件/WEB-INF/jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/jdbc/mysql</jndi-name>
</resource-ref>
</jboss-web>
websphere程序配置
需要在web.xml配置的基础上增加一文件ibm-web-bnd.xmi
<?xml version="1.0" encoding="UTF-8"?>
<webappbnd:WebAppBinding xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:webappbnd="webappbnd.xmi"
xmlns:common="common.xmi" xmi:id="WebAppBinding_1" virtualHostName="default_host">
<webapp href="WEB-INF/web.xml#WebApp" />
<resRefBindings xmi:id="ResourceRefBinding_123"
jndiName="jdbc/mysql">
<bindingResourceRef href="WEB-INF/web.xml#ResourceRef_123" />
</resRefBindings>
</webappbnd:WebAppBinding>