Hi Chris, Thanks for the info about the struts 1.3. If you didnt say that, i would pack everything up and deploy on a school server for my demo next week. So now I gotta change back to container-managed dataSource. As I said, i did declare the tomcat dataSource in server.xml and WEB-INF/web.xml. As you said, i should write a class which extend the struts Action class then overwrite the getDatasource() method in such a way that it gonna return the datasource that i have declared in server.xml and web.xml, but how can i access the container-managed datasource from my custom action class? My server.xml has: <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="/Core1" docBase="Core1" debug="5" reloadable="true" crossContext="true"> <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="myname" password="mypass" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/core?autoReconnect=true"/> </Context> </Host> And my WEB-INF/web.xml is <resource-ref> <description>DB connection</description> <res-ref-name>jdbc/TestDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> Hope you can give some suggestion Thanks in advance Thai Christopher Schultz <[EMAIL PROTECTED]> wrote: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Thai, Nhut Thai Le wrote: > Servlet decument says: getDatasource(HTTPServletRequest) is used to > get the default datasource, getDataSource(HttpServletRequest, String) > get the selected datasource. This appears to be a Struts method, not anything from the servlet specification. You need to be very specific when you quote things like this. http://struts.apache.org/1.2.9/api/org/apache/struts/action/Action.html#getDataSource(javax.servlet.http.HttpServletRequest) > However, since I am using struts. following instruction in tomcat > documentation on connection pooling and using getDatasource within a > struts action class give a null resource because although action > class has getDatasource(HttpServletRequest) as the httpServlet class, > it only return resource which is managed by strut not the from > container as the httpServlet object does. Exactly. If you are using Tomcat-managed DataSources, you cannot use Struts's Action.getDataSource method. You will have to write your own. If you have a base action from which all your existing actions extend, you can simply override getDataSource and implement it correctly for a JNDI-based DataSource. Better yet, separate your database queries from your Struts actions, and forget Action.getDataSource ever existed. > I'm now letting struts manages the resource. My problem is partly > solved for now. You should NOT do this. Struts has abandoned DataSource management as of version 1.3 in favor of container-managed DataSources (as it should have been all along). You should get Tomcat-based DataSource management working. We will help you, though I'm guessing that this thread is over and nobody will read this follow-up. :( - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGklYb9CaO5/Lv0PARAmWpAJ9TJ+97VfAs5PrE0C240355BixskQCgrdmY kZK5rfPcUHqyi8bzgjTMrDg= =Vjnk -----END PGP SIGNATURE----- --------------------------------------------------------------------- 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 --------------------------------- Luggage? GPS? Comic books? Check out fitting gifts for grads at Yahoo! Search.