1.Create a data source descriptor file named $CATALINA_HOME/conf/context.xml and insert the following lines:
<Context>
…
<Resource name="jdbc/mysqlDB" auth="Container" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://<IP_OR_NAME_OF_MYSQL_SERVER>:3306/<DATABASE_NAME>"
username="<DB_USERNAME>"
password="<DB_PASSWORD>" maxActive="10" maxIdle="10"
<Resource name="jdbc/mysqlDB" auth="Container" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://191.168.1.100:3306/osmsdb" username="osmsusr" password="osmspass" maxActive="10" maxIdle="10"
To configure the MySQL database, perform the following steps on the MySQL server:
1.Verify that the MySQL server is running properly by entering the following command:
# psIf the MySQL server is running, a process named mysqld displays in the output; otherwise, enter the following command:
#/etc/init.d/mysql start2.If the database used in the Tomcat data source does not exist, create the database by entering the following command:
#mysqladmin3.If the database user in the Tomcat data source does not exist, create the user and grant the appropriate privileges by entering the following commands from the mysql prompt:
mysql> grant all on osmsdb.* to osmsuser@'%.%.%.%' identified by \ 'osmsuser';mysql> flush privileges;The user named osmsuser with the password osmspass is created and is granted all operation privileges on the database osmsdb.
Testing MySQL Database ConnectivityTo test the connectivity between Tomcat and MySQL, perform the following steps on the Tomcat web server:
32