2016-12-02 160 views
0

Jetty手册提供了连接池示例,BoneCP,c3p0,DBCP但不包含tomcat-jdbc。 是否可以使用tomcat-jdbc连接池配置Jetty?Jetty with tomcat-jdbc连接池

+0

此配置,您应该能够通过JNDI,是的。该文档提供了许多示例,但无法涵盖所有​​情况。 – Walkerwatch

回答

1

我一直在使用与码头9.3和tomcat-JDBC 7.0.72

<!-- =========================================================== --> 
    <!-- DataSource             --> 
    <!-- =========================================================== --> 

    <New id="rfid" class="org.eclipse.jetty.plus.jndi.Resource"> 
    <Arg>jdbc/rfid</Arg> 
    <Arg> 
     <New class="org.apache.tomcat.jdbc.pool.DataSource"> 
     <Set name="driverClassName">oracle.jdbc.OracleDriver</Set> 
     <Set name="url">jdbc:oracle:thin:@integra:1521:integra</Set> 
     <Set name="username">user</Set> 
     <Set name="password">password</Set> 
     <Set name="defaultAutoCommit">false</Set> 
     <Set name="jmxEnabled">true</Set> 
     <Set name="testWhileIdle">false</Set> 
     <Set name="testOnBorrow">true</Set> 
     <Set name="testOnReturn">false</Set> 
     <Set name="validationQuery">SELECT 1 FROM dual</Set> 
     <Set name="validationInterval">30000</Set> 
     <Set name="minEvictableIdleTimeMillis">30000</Set> 
     <Set name="timeBetweenEvictionRunsMillis">30000</Set> 
     <Set name="initialSize">8</Set> 
     <Set name="minIdle">8</Set> 
     <Set name="maxIdle">8</Set> 
     <Set name="maxActive">10</Set> 
     <Set name="maxWait">30000</Set> 
     <Set name="removeAbandonedTimeout">120</Set> 
     <Set name="logAbandoned">true</Set> 
     <Set name="removeAbandoned">true</Set> 
     <Set name="jdbcInterceptors"> 
      org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport(threshold=2000); 
      org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmx; 
     </Set> 
     </New> 
    </Arg> 
    </New> 

    <New id="myphoto" class="org.eclipse.jetty.plus.jndi.Resource"> 
    <Arg>jdbc/myphoto</Arg> 
    <Arg> 
     <New class="org.apache.tomcat.jdbc.pool.DataSource"> 
     <Set name="driverClassName">com.mysql.jdbc.Driver</Set> 
     <Set name="url">jdbc:mysql://localhost:3306/myphotoipb?zeroDateTimeBehavior=convertToNull&amp;useSSL=false</Set> 
     <Set name="username">myphoto</Set> 
     <Set name="password">password</Set> 
     <Set name="defaultAutoCommit">false</Set> 
     <Set name="jmxEnabled">true</Set> 
     <Set name="testWhileIdle">false</Set> 
     <Set name="testOnBorrow">true</Set> 
     <Set name="testOnReturn">false</Set> 
     <Set name="validationQuery">SELECT 1 FROM dual</Set> 
     <Set name="validationInterval">30000</Set> 
     <Set name="minEvictableIdleTimeMillis">30000</Set> 
     <Set name="timeBetweenEvictionRunsMillis">30000</Set> 
     <Set name="initialSize">2</Set> 
     <Set name="minIdle">4</Set> 
     <Set name="maxIdle">8</Set> 
     <Set name="maxActive">10</Set> 
     <Set name="maxWait">30000</Set> 
     <Set name="removeAbandonedTimeout">120</Set> 
     <Set name="logAbandoned">true</Set> 
     <Set name="removeAbandoned">true</Set> 
     <Set name="jdbcInterceptors"> 
      org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport(threshold=2000); 
      org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmx; 
     </Set> 
     </New> 
    </Arg> 
    </New> 
+0

它的工作原理。非常感谢。 – cdeep