Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 469
Amir Raminfar Avatar asked Jan 24 '11 15:01

Amir Raminfar


People also ask

What is server xml file in Tomcat?

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.

What is the use of context xml in Tomcat?

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.

How do I set DataSource in Tomcat context xml?

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.

What is the use of server xml?

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.


1 Answers

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.

like image 113
BalusC Avatar answered Sep 21 '22 17:09

BalusC