Search code examples
javatomcatjndiapache-commons-dbcp

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


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"?


Solution

  • 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.