This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Configure Tomcat & Mysql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Configure Tomcat & Mysql" Watch "Configure Tomcat & Mysql" New topic
Author

Configure Tomcat & Mysql

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Hey ranchers.
I am using Tomcat and I want to add a datasource.
what is the best place to add a datasource to server.xml file ?
before the closing </host> element close to the end of the file ?
I have been reading that mysql user account should has a password in
order to be tomcat able to connect...
but when installing mysql, I didn't create any account (I mean, when
I connect to mysql, I don't provide any passwords or usernames).
so I think to do the following to server.xml :
<parameter>
<name>username</name>
<value></value>
</parameter>
and the some thing to the password....
please correct me if I am wrong.
also, I have been reading that I need to grant the appropriate priviliges
for tomcat to be able to connect to mysql using the username and the
password.
the command is :
grant all privileges on *.* to admin@localhost indentified by 'admin'
with grant option;
so what to do in my case (there is no user account and password in mysql) ?
admin in admin@localhost is the name that I have provided when installing
tomcat, right ?
thanks alot.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

You can set your datasource resource ID at the global (server.xml) level or at the individual webapp level. Where I work, we have different webapps running against different databases, so to configure them, I create a "webapp.xml" file and put it in the Tomcat webapps directory. It has the database resource definitions, the security resource definitions, and the application context.

Caution: In Tomcat 4.1, having a WAR file with the same name as a webapp xml file will hide the config info in the webapp xml. So I put my wars in their own special directory (/opt/webapps). The rules are different for Tomcat 5, however.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Configure Tomcat & Mysql
 
Similar Threads
Tomcat 4.1.31 Connection Pooling Problem
DataSource Invalid
connector/J with my SQL.. Driver fails to load!
How to encrypt the datasource password
Tomcat Connection Pooling Help required