![jboss 5.1 mysql 连接池](https://linux22.com/image/539357/jboss%205.1%20mysql%20%E8%BF%9E%E6%8E%A5%E6%B1%A0.png)
我正在使用 JBOSS 5.1.0.GA、MySQL 5.5 和 Hibernate 3.3.1 GA(包含在 JBOSS 中)+ Spring。
我的问题是,我是否需要在我的 spring/hibernate 配置中添加 c3p0 作为连接池的数据源,或者 JBOSS mysql-ds.xml 设置中的设置是否足够。
我的 mysql-ds.xml 如下:
<datasources>
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/ecotrak</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>ecotrak</user-name>
<password>ecotrak</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>5</idle-timeout-minutes>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<!-- should only be used on drivers after 3.22.1 with "ping" support -->
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
答案1
JBoss DataSource 有自己的连接池,从部署在其上的 spring 应用程序只需使用 jndi 数据源即可
http://pro-programmers.blogspot.com/2008/07/spring-datasource-jndi-lookup-from.html