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>
<link rel="stylesheet" href="style_master.css" type="text/css"> <meta
</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
}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.jspThe test page opens as shown in Figure 12.Figure 12 Tomcat Connecting MySQL Test PageConnecting Tomcat and Oracle
Oracle is the leading commercial relational database. It is generally used to store and manage sensitive and
Installing, Configuring, and Managing Web Server Middleware Stack Components 33