HP OSMS Blueprint: Database Server on HP Server Platforms with MySQL and RHEL5

5. To enable MySQL data sources in Tomcat, create a file named context.xml using your
favorite text editor. This file should be located in
$TOMCAT/webapps/osmsexample/META-INF/context.xml and should consist of the
following lines:
<Context path="/osmsexample" docBase="osmsexample" debug="0" reloadable="true">
<Resource name="jdbc/rwDS" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="osmsusr" password="osmspass" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://<DB_Server_IP>/osmsdb"/>
<Resource name="jdbc/roDS" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="osmsusr2" password="osmspass2" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://<DB_Server_IP>/osmsdb"/>
</Context>
6. To enable a new web application in Tomcat, create a file named web.xml using your favorite
text editor. This file should be located in
$TOMCAT/webapps/osmsexample/WEB-INF/web.xml and should consist of the following
lines:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>MySQL List user Examples</display-name>
<description>Servlet 2.4 Examples</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/rwDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/roDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
7. To create the test application in Tomcat, create a file named list.jsp using your favorite
text editor. This file should be located in $TOMCAT/webapps/osmsexample/list.jsp
and consist of the following:
<%@ page
import = "java.io.*"
import = "java.lang.*"
import = "java.sql.*"
import = "javax.naming.*"
import = "javax.sql.*"
%>
<%@ page contentType="text/html;"%>
<html><head>
<title>Test Tomcat JDBC Connection to MySQL Database</title>
</head>
<body>
<%
//read-only data source
//String dsName ="jdbc/roDS";
//read-write data source
String dsName ="jdbc/rwDS";
StringBuffer tableHead = new StringBuffer();
StringBuffer tableData = new StringBuffer();
Context initCtx =null;
DataSource myDataSource=null;
Connection con = null;
PreparedStatement preStmt = null;
ResultSet searchResult = null;
%>
<%
//write to database
try{
initCtx = new InitialContext();
34