Hi Riann,
I have successfully implemented a globally available DataSource within my
server.xml. What follows are the relevant excerpts from my server.xml file
that enabled me to do this. FYI - I am using Tomcat 4.1.24.
The global DataSource definition
--------------------------------
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Editable user database that can also be used by JNDI
DatabaseRealm to authenticate users -->
<Resource name="jdbc/MySQLConnectPool"
auth="Container"
type="javax.sql.DataSource" />
<ResourceParams name="jdbc/MySQLConnectPool" >
<parameter>
<name>username</name>
<value>????????</value>
</parameter>
<parameter>
<name>password</name>
<value>????????</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://<your IP here>:3306/<your DB name
here>?autoReconnect=true</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>60</value>
</parameter>
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>200</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30000</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>100</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
Realm definition using global DataSource
----------------------------------------
<Realm
className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="jdbc/MySQLConnectPool"
userTable="customers"
userNameCol="customer_username"
userCredCol="customer_password"
userRoleTable="roles"
roleNameCol="role"
debug="0"
/>
Context reference to global DataSource
--------------------------------------
<ResourceLink name="jdbc/MySQLConnectPool"
global="jdbc/MySQLConnectPool"
type="javax.sql.DataSource" />
Hope this helps!!
Thanks,
Scott Stewart
[EMAIL PROTECTED]
-----Original Message-----
From: Riaan Oberholzer [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 9:26 AM
To: [EMAIL PROTECTED]
Subject: [Q] server.xml vs context.xml ?
I've had the problem where defining a Datasource in a
server.xml (as sub element of the context element) did
not work, but moving it to a context.xml for the
application (named 'appname.xml' eg) it worked fine.
What is the general rule regarding when to declare
e.g. Datasources for a specific application in the
server.xml and when to put it in a context.xml? The
Tomcat HOW-TO documentation explains that you must do
it in the server.xml, but this doesn't sound like the
best solution to me.
Why would one method work and the other not? Pro's &
con's of each? The obvious difference is that updating
server.xml would require a server restart where
working with a context.xml does not. But in the
server.xml you can specify resources globally for for
all apps, right? I tried this first, but couldn't get
it working... only when the resource was specific to
my application could I actually use it without getting
errors.
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]