6

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

skaffman
  • 398,947
  • 96
  • 818
  • 769
Amir Raminfar
  • 33,777
  • 7
  • 93
  • 123

1 Answers1

8

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks this is the answer I was looking for. Last question, if I was to create my connection pool implementation (not for production but for a home project to learn) where would be a good place to start? I was thinking of just looking at the source code on tomcat-jdbc-pool. But maybe you have a better place to start. – Amir Raminfar Jan 24 '11 at 16:16
  • [Here's](http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html) a basic Sun/Oracle tutorial. Warning: the example implementation is very poor. Do not use it for real production! For example, it does not check nor limit the maximum amount of pooled connections. – BalusC Jan 24 '11 at 16:19
  • Hmm i already saw that one. Yea it didn't really tell me anything I didn't know. I was going to just use a simple BlackingArrayQueue in Java that holds a pool of connections to see what the performance would be. I have an idea on where to start. I can't find the source for tomcat-jdbc-pool? – Amir Raminfar Jan 24 '11 at 16:23
  • It are the ones with `src` in filename [here](http://people.apache.org/~fhanik/jdbc-pool/). That link by the way comes from the linked related question :) – BalusC Jan 24 '11 at 16:25