HP (Hewlett-Packard) 5991-5565 Network Card User Manual


 
1. Create a JSP file named $CATALINA_HOME/webapps/ROOT/mysqltest.jsp and insert
the following lines:
<%@page contentType="text/html" import="java.io.*,java.sql.*,
javax.sql.*,javax.naming.*"%>
<html>
<head>
<title>Tomcat->MySQL Test </title>
<link rel="stylesheet" href="style_master.css" type="text/css">
<meta http-equiv="cache-control" content="no-cache">
</head>
<body>
<%
InitialContext ctx = new InitialContext();
DatabaseMetaData dm = null;
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/mysqlDB");
Connection conn = null;
Statement stmt = null;
try {
conn = ds.getConnection();
dm =conn.getMetaData();
out.println("Connected to-> database version"
+dm.getDatabaseProductVersion());
}catch (Exception sqlex) {
out.println(sqlex.getMessage());
}finally{
conn.close();
}
%>
</body>
</html>
2. If needed, start Tomcat by entering the following command:
# $CATALINA_HOME/bin/startup.sh
3. Verify Tomcat is connecting to MySQL by opening a browser and navigating to the following
website:
http://<YOUR_HOSTNAME>:8080/mysqltest.jsp
The test page opens as shown in Figure 12.
Figure 12 Tomcat Connecting MySQL Test Page
Connecting Tomcat and Oracle
Oracle is the leading commercial relational database. It is generally used to store and manage
sensitive and mission-critical data. As with MySQL, Oracle can also be used as the persistence
Installing, Configuring, and Managing Web Server Middleware Stack Components 33