朋友,急啊!一个奇怪JSP连接MySQL问题,在线等........
小弟最近十分恼火,为解决这个问题都有近10天了,天天都在找资料改,还是找不到原因。难道MySQL 4.0.12不支持windows XP吗?还是必须有apache。
系统 : Windows XP professional;
环境变量:
classpath : C:\JAVA\lib; C:\JAVA\dt.jar; C:\JAVA\tools.jar;
C:\TOMCAT\common\lib\servlet.jar;
C:\TOMCAT\bin\bootstrap.jar
!!!!(org\gjt\mm\mysql\Driver放在C:\JAVA\lib内)!!!!。
CATALINA_HOME : C:\TOMCAT (以前用TOMCAT_HOME也是)
JAVA_HOME : C:\JAVA
PATH : C:\JAVA\bin
问题说明 : 运行时JSP页面除了调用MySQL的没显示,其他的都有。
源代码如下:customer.JSP (后缀用的是大写,小写时要报内部出错)
<!-- JSP Directives -->
<%@ page import="java.sql.*" %>
<html>
<head>
<title>Insurance Quoting System</title>
</head>
<body>
<basefont face="Arial">
<!-- JSP Declarations -->
<%! ResultSet rs = null; %>
<!-- JSP Scriptlet -->
<%
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection db = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/quoting","root","");
Statement s = db.createStatement();
rs = s.executeQuery("select * from customer");
}
catch (Exception e) {
// For now, just report the error to the system log
System.out.println(e.toString());
}
%>
<!-- Template text -->
<table width="550" border="0" align="center">
<tr>
<td bgcolor="#006633">
<div align="center">
<font size="6" color="#FFFFFF">
<b>Insurance Quoting System</b>
</font>
</div>
</td>
</tr>
<tr>
<td>
<p> </p>
<p> </p>
<p align="center"><b>Customers</b></p>
<table width="290" border="0" align="center">
<%
try {
while (rs.next()) {
%>
<!-- JSP Expressions used within template text -->
<tr>
<td width="20"><%= rs.getInt(1) %></td>
<td width="70"><%= rs.getString(2) %></td>
<td width="70"><%= rs.getString(3) %></td>
<td width="40">
<a href="custMaint.jsp?id=<%= rs.getString(1) %>&action=edit">
edit
</a>
</td>
<td width="40">
<a href="custMaint.jsp?id=<%= rs.getString(1) %>&action=delete">
delete
</a>
</td>
<td width="40">
<a href="custMaint.jsp?id=<%= rs.getString(1) %>&action=newQuote">
newQuote
</a>
</td>
</tr>
<%
}
}
catch (SQLException e) {
// For now, just report the error to the system log
System.out.println(e.toString());
}
%>
</table>
</td>
</tr>
<tr>
<td>
<p> </p>
<p align="center"><a href="custMaint.jsp?action=add">New Customer</a></p>
</td>
</tr>
</table>
</body>
</html>
先谢谢大家了!!!!!!!!!!