Re: Struts & Mysql - can't get to server.xml must put in struts-config
Posted by: Mark Matthews
Date: March 06, 2005 04:41PM

wes wrote:
> Hello all. I've developed a Struts application
> and used the JNDI data source in the server.xml
> file. I've deployed it to the host and it's been
> working great. I have a virtual Tomcat
> installation that I have access to the server.xml
> file so I created the datasource in the Container.
> I've got to use connection pooling, obviously, but
> I'm not sure how to set this up. I can model the
> <data-source> in struts-config.xml for the
> struts-blank WAR, but I'm not totally sure what to
> use for the <data-source type=??> I've got
> the driverClassName (com.mysql.jdbc.Driver) and
> the url: "jdbc:mysql://localhost/databaseName"
> My question would be:
> 1) What should the <data-source type...>
> be?
> 2) How do I change the method of getConnection()
> to use this datasource
> 3) Is there anything else I could/should be
> doing?
> All the examples I've seen use the server.xml -
> JNDI solution. I'm having a heck of a time trying
> to find an example using the struts-config.xml
> file to set this up. I'm assuming I'll need an
> entry in the web.xml file too?
> Sorry, I'm still kinda new to all this. So many
> places to look - struts, tomcat, mysql... It's
> all confusing at this point and not being able to
> find some examples is making it worse. Anyone able
> to help? I'd truly appreciate it!
> TIA!


If you've got the stuff localized in one class for a DAO, I'd suggest dumping DBCP and using C3P0, which does connection pooling, and you can create a single static instance of it in your DAO and treat it like a normal java object, see:

If you download the package, there are examples of how to setup/configure a connection pool. I've found C3P0 to be quite a bit more robust than all but the latest versions of DBCP.


Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools

Options: ReplyQuote

Written By
Re: Struts & Mysql - can't get to server.xml must put in struts-config
March 06, 2005 04:41PM
March 30, 2005 06:26AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.