commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Les Hazlewood" <...@hazlewood.com>
Subject [DBCP] JNDI, Tomcat, Distributed Apps, et al.
Date Sat, 15 Jun 2002 21:09:46 GMT
Hey folks, 

I've been well-immersed in the dbcp code and the jndi tutorial the last 
week, and I have some questions concerning the dbcp commons project. 

I have just recently implemented DBCP in my webapp using Tomcat per the 
instructions on the JNDI Resources How-To: 
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-resources-howto.html 

Its great!  Thanks for the tool. 

I'd like to address 3 areas of confusion: 


Situation 1: 

I'd like to use the DBCP in a JNDI lookup from outside a webapp container 
like Tomcat.  I.E. I'd like to do it in a standalone application as well 
that accesses the same database. 

After all the reading I've done, I'm still wondering if there is a way to do 
a JNDI lookup to return a BasicDataSource in my standalone app, just like 
Tomcat does for my webapp. 

Can I specify the DB parameters in a jndi.properties file that my standalone 
app accesses, just like Tomcat's server.xml specifies Resources and 
ResourceParams? (i.e. maxActive, maxIdle, url, etc in a jndi.properties 
file). 

If we CAN specify such properties and access them throughout the webapp, 
what is the point of specifying them in Tomcat's server.xml file?  I ask 
because if we need JNDI lookup of a DataSource in Tomcat you have to 
manually configure the server.xml file to use it.  This goes against the 
principle of packaging things in a nice self-contained .war file and having 
the application work just by dropping it in to the webapp directory (that 
is, there should be no external configuration necessary outside of the war 
context). 


Situation 2: 

I've noticed that the BasicDataSourceFactory creates a new instance of a 
Datasource, which intuitively means it has its own pool of connections 
withing the memory space of the JVM that created it.  For distributed 
applications that exist on multiple JVM's but access the same database, this 
would mean a DataSource object with a corresponding connection pool exists 
per JVM. 

When I specify things such as maxIdle, maxConnections, etc., I'd like that 
to correspond to global settings for my database.  For example, lets say I 
know database x can handle 50 open connections concurrently, so no matter 
how many distributed applications that access my database, I don't want more 
than 50 connections total to be pooled across all pooled applications. 

The only way I can think of doing this is to create a single instance of a 
DataSource via a JNDI lookup, and then bind this DataSource object in a JNDI 
Context.  Then all other applications can do a JNDI lookup on this bound 
object, and just use it as if they created the DataSource themselves. 

However, I'm not entirely sure this is possible, if it requires things like 
Serialization, or behind-the-scenes RMI, of which I'm not clear since I'm 
not a JNDI expert by any means.  Any ideas? 


Situation 3: 

I've noticed DBCP doesn't use things like the newer JDBC standardized 
interfaces such as ConnectionPoolDataSource and PooledConnection. 

These are Java SQL Standards, and I was wondering if there are any plans to 
incorporate these soon or what measures have been done already.  I feel its 
important to adhere to the standards, and Apache has always been great about 
that. 

Your thoughts? 


Thanks a ton, 

Les Hazlewood

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message