我有一个使用JDBC连接池的spring web应用程序(在glassfish服务器上)。它在XML文件中定义如下:
<resources>
<jdbc-connection-pool allow-non-component-callers="true" associate-with-thread="true"
connection-creation-retry-attempts="2" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false"
connection-leak-timeout-in-seconds="0" connection-validation-method="table" datasource-classname="oracle.jdbc.pool.OracleConnectionPoolDataSource"
fail-all-connections="false" idle-timeout-in-seconds="2147483638" is-connection-validation-required="true"
is-isolation-level-guaranteed="false" lazy-connection-association="true" lazy-connection-enlistment="true"
match-connections="false" max-connection-usage-count="0" max-pool-size="60" max-wait-time-in-millis="60000"
name="company.jdbc.sc.nonxa.pool" non-transactional-connections="false" pool-resize-quantity="2"
res-type="javax.sql.ConnectionPoolDataSource" statement-timeout-in-seconds="300" steady-pool-size="16"
transaction-isolation-level="read-committed" validate-atmost-once-period-in-seconds="1" validation-table-name="SC_VALIDATE"
wrap-jdbc-objects="false">
<property name="DataSourceName" value="OracleNonXADataSource"/>
<property name="ImplicitCachingEnabled" value="false"/>
<property name="NetworkProtocol" value="tcp"/>
<property name="Password" value="password"/>
<property name="LoginTimeout" value="0"/>
<property name="URL" value="jdbc:oracle:thin:@oradbdev.company.ru:1521:COMPANY"/>
<property name="NativeXA" value="false"/>
<property name="User" value="prog10"/>
<property name="ExplicitCachingEnabled" value="false"/>
<property name="PortNumber" value="0"/>
<property name="MaxStatements" value="0"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="company.jdbc.sc.nonxa.db" object-type="user" pool-name="company.jdbc.sc.nonxa.pool"/>
</resources>
现在我需要在嵌入式Jetty服务器内启动应用程序进行集成测试。 我正在尝试在jetty.xml文件中添加连接池,如下所示:
<New id="DS" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>
<Ref id="wac"/>
</Arg>
<Arg>jdbc/DS</Arg>
<Arg>
<New class="oracle.jdbc.pool.OracleConnectionPoolDataSource">
<Set name="DataSourceName">OracleNonXADataSource</Set>
<Set name="ImplicitCachingEnabled">false</Set>
<Set name="NetworkProtocol">tcp</Set>
<Set name="Password">password</Set>
<Set name="LoginTimeout">0</Set>
<Set name="URL">jdbc:oracle:thin:@oradbdev.company.ru:1521:COMPANY</Set>
<Set name="NativeXA">false</Set>
<Set name="User">prog10</Set>
<Set name="ExplicitCachingEnabled">false</Set>
<Set name="PortNumber">0</Set>
<Set name="MaxStatements">0</Set>
</New>
</Arg>
</New>
注册连接池,但我也需要注册给定名称的jdbc-resource。
我该怎么做?
答案 0 :(得分:2)
使用Jetty,您可以在配置中设置连接池的JNDI名称(此处为jdbc/DS
)。那你为什么需要注册一个“jdbc-resource”呢?这似乎是GlassFish的一个具体步骤。