【发布时间】:2012-03-01 07:59:34
【问题描述】:
我使用的是 Tomcat 的 7 连接池。我的配置如下:
在server.xml:
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="jdbc_DS" auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="org.h2.Driver"
url="jdbc:h2:file:absolutePathtodatabase"
username="root" password=""
maxActive="20" maxIdle="10" maxWait="-1"
/>
</GlobalNamingResources>
在 context.xml 中:
<ResourceLink name="jdbc/myDS"
global="jdbc_DS"
type="javax.sql.DataSource"/>
它似乎有效,但我注意到以下内容:
在资源here:global resources 的属性中,它没有提到factory 作为Resource 的属性。尽管如此我已经在server.xml 中定义了它并且没有错误。
这是什么意思?我不是在这里使用org.apache.tomcat.jdbc.pool.DataSourceFactory 工厂吗?
【问题讨论】:
标签: java jakarta-ee web-applications tomcat jdbc