SSH中JNDI(mysql的连接池)的配置

女生的网名这么多〃 提交于 2020-01-09 13:55:07

1):

  在tomcat的配置路径下的context.xml中添加如下代码:

  

<Resource name="jdbc/cmis"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="50"
maxWait="15000"
username="root"
password=""
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/mdym" />

2):

  在要引用JNDI的工程中的WEB-INF的web.xml中添加如下代码:

<resource-ref>
<res-ref-name>jdbc/cmis</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

3):

  在spring的hibernate的配置文件中添加如下代码:

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/cmis</value>
</property>
</bean>

4):

commons-pool.jar

sqljdbc4.jar

两个.jar文件必须放在tomcat配置路径下的lib文件夹里

  

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!