Is the factory attribute for tomcat's server.xml required?

半城伤御伤魂 提交于 2020-08-02 07:48:28

问题


I have been reading more on JNDI in tomcat and I have read from multiple resources that the factory attributed is required. They say its often supposed to be "org.apache.tomcat.jdbc.pool.DataSourceFactory". However, most often I see something like this -

 <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"
               url="jdbc:mysql://localhost:3306/javatest"/>

So what does tomcat do in this case? Does it default to "org.apache.tomcat.jdbc.pool.DataSourceFactory"?


回答1:


The org.apache.tomcat.jdbc.pool.DataSourceFactory is not the default factory. It's the new Tomcat 7.0 builtin high-performance connection pool which is supposed to replace the default DBCP.

The default factory is the org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory. See also the JNDI resources HOW TO. The attribute is indeed not required.



来源:https://stackoverflow.com/questions/4784044/is-the-factory-attribute-for-tomcats-server-xml-required

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