问题
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