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.
[snip]
> 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!

Wes.

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:

http://sourceforge.net/projects/c3p0

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

Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html

Options: ReplyQuote


Subject
Written By
Posted
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.