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"?
The server. xml file is Tomcat's main configuration file, and is responsible for specifying Tomcat's initial configuration on startup as well as defining the way and order in which Tomcat boots and builds. The elements of the server.
In Tomcat, the Context Container represents a single web application running within a given instance of Tomcat. A web site is made up of one or more Contexts. For each explicitly configured web application, there should be one context element either in server. xml or in a separate context XML fragment file.
Application context. xml - This is the easiest way to configure DataSource, all we need is a context. xml file in META-INF directory. We have to define Resource element in the context file and container will take care of loading and configuring it.
The server. xml file contains most of the server configuration. This chapter describes the basic syntax of the server. xml file and provides a high-level view of the elements that are used to configure features of the server.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With