HP 5991-5565 Manuel d'utilisateur Page 33

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 57
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 32
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
Vue de la page 32
1 2 ... 28 29 30 31 32 33 34 35 36 37 38 ... 56 57

Commentaires sur ces manuels

Pas de commentaire