The docs should have been clear the context.xml to modify would exist in one of a couple of places:

- context.xml file in DbTest/META-INF
- DbTest.xml in $CATALINA_HOME/conf/Catalina/localhost

Also username/password for the db connection should *NOT* be the root/admin user/password for your database. That's just a huge, crazy security hole waiting to be exploited. Create a new user in MySQL with privileges on the javatest database and use that in the Resource username and password attributes.

You can do this easily using the MySQL command line tool (and the root MySQL account):

grant all on javatest.* to 'mywebappuser'@'localhost' identified by 'mywebapppassword' ;

This creates a user named 'mywebappuser' with full privileges on the javatest tables. Because I added @'localhost' in the command, the user account is only valid when the user log's in from the same machine MySQL is running on. That helps protect the db server.

Then the Resource element becomes:

<Resource name="jdbc/TestDB" auth="Container"
              type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="mywebappuser" password="mywebapppassword"
              driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/javatest"
              validationQuery="select 1"/>

Note I also dropped ?autoReconnect=true from the url (bad idea to leave that in, I should submit a patch to the tomcat docs at some point), replacing it with a new attribute: validationQuery="select 1"

--David

sam wun wrote:
HI there,



According to the tomcat online document, do I have to modify the context.xml file?

$CATALINA_HOME/conf/context.xml



with the following new setup: <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>



where username/password is the root/admin user/password of the mysql database?



thanks





----- Original Message -----
From: David Smith
Sent: 28/08/08 03:06 am
To: Tomcat Users List
Subject: Re: Can't execute servlet project

The datasource for your webapp isn't setup correctly. Take a look at http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html for help on how to properly setup a database connection pool. My only edit that article I would recommend is don't add ?autoReconnect=true to the end of the mysql database url. Instead, add validationQuery="select 1" to the <Resource ... /> element in your context.xml file so connections are tested and regenerated as needed.

--David



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

Reply via email to