-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thai,
Nhut Thai Le wrote: > 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. You can still do your demo. Just make sure that you eventually convert your configuration, or you'll be stuck on that old version of Struts. > As I said, i did declare the tomcat dataSource in server.xml and > WEB-INF/web.xml. Don't do that. Since you're using Tomcat 5.5, you should declare your DataSource in META-INF/context.xml, along with your Realm. Then, you don't ever have to touch server.xml, which is nice. > 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? The same way you should be accessing a JNDI DataSource from anywhere: import javax.naming.*; import java.sql.Connection; ... String DATASOURCE = "jdbc/TestDB"; String DATASOURCE_PATH = "java:/comp/env/" + DATASOURCE; Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup(DATASOURCE_PATH); Connection conn = dx.getConnection(); Of course, you'll need some error checking, etc. > url="jdbc:mysql://localhost/core?autoReconnect=true"/> Oh, get rid of "autoReconnect", too. See the Connector/J documentation for why you shouldn't use it. See the documentation reference that Davis posted, too. It should lay everything out for you, if I haven't done so already. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGk5BW9CaO5/Lv0PARArxmAJ9F6HDH8UQE7voQhBp4fOEsClyANACcC6tE FbPk6hTJ0tcPY6OgBRwgbOs= =2Vfq -----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]