Re: Configuring a Data Resource in web.xml

2004-02-16 Thread Harry Mantheakis
I not think you can put the JNDI/Resource stuff in the deployment
descriptor, though I stand to be corrected (!)

AFAIK the JNDI/Resource stuff is placed within an application's 'Context'
element.

With Tomcat 5 you can have separate context fragments - individual XML
documents - for each application.

Context fragments are cool because you can update them without having to
touch the server's configuration file (server.xml).

Context fragments reside in $CATALINA_HOME/conf/Catalina/host directory
where host is the name of the relevant host specified in server.xml. The
default host setting is 'localhost'.

I hope that helps!

Harry Mantheakis
London, UK



 The reference book I have shows how to configure a data resource (JDBC) in the
 server.xml.
 
 Does anyone have a reference on how to do this in the web.xml?
 
 I'd like to be able to unpack a war and have everything run, without the need
 to edit the
 server.xml.
 
 Thanks for your help.
 
 Mike
 
 __
 Do you Yahoo!?
 Yahoo! Finance: Get your refund fast by filing online.
 http://taxes.yahoo.com/filing.html
 
 -
 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]



Re: Configuring a Data Resource in web.xml

2004-02-16 Thread Jacob Kjome
At 10:16 AM 2/16/2004 +, you wrote:
I not think you can put the JNDI/Resource stuff in the deployment
descriptor, though I stand to be corrected (!)
Well, get ready to start standing

  resource-ref
  descriptionDB Connection/description
  res-ref-namejdbc/TestDB/res-ref-name
  res-typejavax.sql.DataSource/res-type
  res-authContainer/res-auth
  /resource-ref
That goes in your web.xml.  Of course, you are right about the rest.   You 
need to provide the configuration for the jdbc/TestDB Datasource

http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html

Jake


AFAIK the JNDI/Resource stuff is placed within an application's 'Context'
element.
With Tomcat 5 you can have separate context fragments - individual XML
documents - for each application.
Context fragments are cool because you can update them without having to
touch the server's configuration file (server.xml).
Context fragments reside in $CATALINA_HOME/conf/Catalina/host directory
where host is the name of the relevant host specified in server.xml. The
default host setting is 'localhost'.
I hope that helps!

Harry Mantheakis
London, UK


 The reference book I have shows how to configure a data resource (JDBC) 
in the
 server.xml.

 Does anyone have a reference on how to do this in the web.xml?

 I'd like to be able to unpack a war and have everything run, without 
the need
 to edit the
 server.xml.

 Thanks for your help.

 Mike

 __
 Do you Yahoo!?
 Yahoo! Finance: Get your refund fast by filing online.
 http://taxes.yahoo.com/filing.html

 -
 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]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Configuring a Data Resource in web.xml

2004-02-16 Thread Harry Mantheakis
 Well, get ready to start standing

I knew about the bit that goes in the deployment descriptor (!) It was 'the
rest' I was referring to :-)


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Configuring a Data Resource in web.xml

2004-02-16 Thread SMaric
Have used this for MySQL DB - am NOT totally sure that it is completely
correct

This is what works for me - (see NOTES at end - if anyone can shed any light
on Limiting Pool size)

#1in your Server.xml
GlobalNamingResources
Resource name=MySQLDataSourceFactory
type=com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
auth=Container/
ResourceParams name=MySQLDataSourceFactory
parameter
namefactory/name

valuecom.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory/value
/parameter
parameter
nameport/name
value3306/value
/parameter
parameter
nameuser/name
valuedbUsername/value
/parameter
parameter
namepassword/name
valuedbUserPassword/value
/parameter
parameter
nameserverName/name
valuedbHostIP_Name/value
/parameter
parameter
namedatabaseName/name
valuedbName/value
/parameter
/ResourceParams
.
/GlobalNamingResources

#2in your Context section (either in its own context fragment file or
Context section of server.xml)
Context
className=org.apache.catalina.core.StandardContext
backgroundProcessorDelay=-1
cachingAllowed=true
charsetMapperClass=org.apache.catalina.util.CharsetMapper
configFile=..\Catalina\localhost\yourContextFragment.xml *
NOT req'd if your Context is defined in server.xml
cookies=true
crossContext=false
debug=9
displayName=Your webApp name to be displayed in webApp manager
docBase=../yourWebApp.war
* NOT req'd if deploying via Tomcat WebApp manager - see NOTEs below
domain=Catalina
engineName=Catalina
j2EEApplication=none
j2EEServer=none
lazy=true
managerChecksFrequency=6
path=/yourWebAppContextPath
privileged=false
reloadable=false
startupTime=47
swallowOutput=false
tldScanTime=875
useNaming=true
wrapperClass=org.apache.catalina.core.StandardWrapper
ResourceLink
global=MySQLDataSourceFactory the JNDI
name as defined in GlobalNamingResources|Resource
name=jdbc/yourJNDIResourceDBName the JNDI name
as used in your webApp code - see below
type=javax.sql.DataSource/
/Context

#3you can test this with the following code fragment
System.out.println(Getting Context info);
Context initCtx = new InitialContext();
System.out.println(Got Initial Context);
Context envCtx = (Context)initCtx.lookup(java:comp/env);
System.out.println(Got JWSDP Environment Context);
try{
System.out.println(Getting MySQL DataSource);
DataSource ds =
(DataSource)envCtx.lookup(jdbc/yourJNDIResourceDBName);
if(ds != null)
{
System.out.println(Got MySQL DataSource);
Vector vConns = new Vector();
try{
for(int i = 0; i  SOMEREASONABLYLARGENUMBER; i++)
{
vConns.add(ds.getConnection());
System.out.println(Got MySQL DB Connection ' + i + '
from Pool);
}
}catch(Exception eX){
eX.printStackTrace();
}finally{
//*Don't forget to release the DB
Connections**
Iterator iT = vConns.iterator();
while(iT.hasNext())
{
Connection conn = (Connection)iT.next();
conn.close();
}
}
}
else
System.out.println(NULL MySQL DataSource);
}catch(Exception eX){
eX.printStackTrace();
}


NOTEs
1 you do NOT need a resource-ref entry in you web.xml -
the ResourceLink / in your Context definition is an
alternative mechanism  provides the JNDI name translation from your webApp
world to the GLOBAL name in the Container world
2Tomcat WebAdmin tool does NOT show this connection pool in
Resource|Data Sources (so don't waste time looking for it)
3Apparently you can build the Context fragment into the WAR file (will
check this next as it means you can have a self contained webApp that you
can deploy easily via Tomcat Web Manager without Stopping/starting Tomcat
all the time)
4Make sure the MySQL jar file
(mysql-connector-java-3.0.10-stable-bin.jar) is in
...Tomact_Install_Dir\common\lib
5using the jdbc prefix to yourJNDIResourceDBName is just a CONVENTION -
you don'y have to comply with it


Hope this is of use
Any comments/corrections please post a reply

Stefan




Mike Duffy [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 The reference book I have shows how to configure a data resource (JDBC) in
the server.xml.

 Does anyone have a reference on how to do this in the web.xml?

 I'd like to be able to unpack a war and have everything run, without 

Configuring a Data Resource in web.xml

2004-02-15 Thread Mike Duffy
The reference book I have shows how to configure a data resource (JDBC) in the 
server.xml.

Does anyone have a reference on how to do this in the web.xml?  

I'd like to be able to unpack a war and have everything run, without the need to edit 
the
server.xml.

Thanks for your help.

Mike

__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Configuring a Data Resource in web.xml

2004-02-15 Thread Jose Alfonso Martinez
I don't think you can. 

In web.xml you only make the named DataSource available for your webapp, but the 
DataSource must be setted up already (in server.xml)...

Therefore, I think there is no possible way to do it. Does anyone know a solution, I 
will be interested to know it too!

Jose

On Sun, Feb 15, 2004 at 02:58:54PM -0800, Mike Duffy wrote:
 The reference book I have shows how to configure a data resource (JDBC) in the 
 server.xml.
 
 Does anyone have a reference on how to do this in the web.xml?  
 
 I'd like to be able to unpack a war and have everything run, without the need to 
 edit the
 server.xml.
 
 Thanks for your help.
 
 Mike
 
 __
 Do you Yahoo!?
 Yahoo! Finance: Get your refund fast by filing online.
 http://taxes.yahoo.com/filing.html
 
 -
 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]