Hi Johnny,
  The method i used is exactly what instuctructed in the 
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
Except that i dont use JSTL. However, the Datasource should be available when 
application started. Is there any other suggestion?
  Thai
Johnny Kewl <[EMAIL PROTECTED]> wrote:
  
Nhut.... listen I think you mixing two different methods.....
You using a framework that works on Tomcat, and both Struts and Tomcat have 
a way of making a dB pool....
You need to choose one or the other.....
TC uses JNDI... most people I think do it this way, and it will work with or 
without struts....
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html

or do it the Struts way.... I dont use it, so no expert, but heres an 
article
http://forum.java.sun.com/thread.jspa?threadID=5146552&tstart=180

theres actually lots of other ways as well.... but these should work

good luck


----- Original Message ----- 
From: "Nhut Thai Le" 
To: 
Sent: Saturday, July 07, 2007 4:20 PM
Subject: How to use connection pool with tomcat 1.2.9


> Hi guys,
> I 'm developing a simple web app with netbeans with bundle tomcat 1.2.9. 
> I want to use connection pooling fir my web app. Thus, i config as follow:
>
> Here is my server.xml:
> 
> 

> 
> className="org.apache.catalina.mbeans.ServerLifecycleListener" />
> 
> className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
> 
> className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
> 
> > value="30"/>
> > type="org.apache.catalina.UserDatabase"
> description="User database that can be updated and saved"
> 
> factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
> pathname="conf/tomcat-users.xml" />
> 
> 
> > maxThreads="150" minSpareThreads="25" 
> maxSpareThreads="75"
> enableLookups="false" redirectPort="8443" 
> acceptCount="100"
> connectionTimeout="20000" disableUploadTimeout="true" />
> > enableLookups="false" redirectPort="8443" 
> protocol="AJP/1.3" />
> 
> > resourceName="UserDatabase"/>
> > unpackWARs="true" autoDeploy="true"
> xmlValidation="false" xmlNamespaceAware="false">
> > reloadable="true" crossContext="true">
> > type="javax.sql.DataSource"
> maxActive="100" maxIdle="30" maxWait="10000"
> username="me" password="iam" 
> driverClassName="com.mysql.jdbc.Driver"
> 
> url="jdbc:mysql://localhost/mydb?autoReconnect=true"/>
> 
> 
> 
> 
> 
>
> And here is my WEB-INF/web.xml
>
> 
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>
> 
> AccessControl
> com.core1.filter.AccessControl
> 
> 
loginPage

> 
/WEB-INF/authentication/login.jsp

> 
> 
> 
> AccessControl
> /protected/*
> 
> 

> 
> 
com.core1.listener.ResourceManagerListener
> 
> 
> action
> 
> org.apache.struts.action.ActionServlet
> 
> 
config

> 
/WEB-INF/struts-config.xml

> 
> 
> 
debug

> 
2

> 
> 
> 
detail

> 
2

> 
> 2
> 
> 
> action
> *.do
> 
> 
> 
> 30
> 
> 
> 
> 
> index.jsp
> 
> 
> 
> Exception
> /WEB-INF/error/error.jsp
> 
> 
> DB connection
> jdbc/TestDB
> javax.sql.DataSource
> Container
> 
> 
>
> I assume that by referencing the DataSource in WEB-INF/web.xml to the 
> DataSource initialized in server.xml, I can access the Datasource from 
> anywhere. However, in one of my Action Class(i'm using Struts framework) I 
> have the following code
>
> DataSource ds = this.getDataSource(request,"jdbc/TestDB");
> if(ds == null)
> throw new InternalException("datasource is null");
>
> Supprisingly, the exception is thrown! The DataSource is null after all.Is 
> there anything else i have to do? It's been 2 weeks i have stuck with this 
> problem. Hope anyone can give a suggestion
>
> Thai
>
>
> -------------------------
> Where there's will, there's a way
>
> ---------------------------------
> We won't tell. Get more on shows you hate to love
> (and love to hate): Yahoo! TV's Guilty Pleasures list. 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-------------------------
Where there's will, there's a way
 
---------------------------------
We won't tell. Get more on shows you hate to love
(and love to hate): Yahoo! TV's Guilty Pleasures list.

Reply via email to