//JSP程序
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>调查结果</title>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
body {
margin: 4px;
padding: 2px;
}
-->
</style>
</head>
<body>
<%
try{
Class.forName("org.gjt.mm.mysql.Driver");
//加载 mm.mysql.driver
} catch (java.lang.ClassNotFoundException e)
//如果加载时出错,给出相应的错误信息
{
out.print("Class not found exception occur. Message is:");
out.print(e.getMessage());
}
try{
Connection con=null;
ResultSet rs=null;
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/vote?user=root&password=123");
Statement stmt=con.createStatement();
rs = stmt.executeQuery("SELECT * FROM vote");
if(!rs.next())
{out.print("<center>还没有人来投票</center>");
}else{
int all=rs.getInt("num");
int a1=rs.getInt("a1");
int a2=rs.getInt("a2");
int a3=rs.getInt("a3");
int a4=rs.getInt("a4");
int a5=rs.getInt("a5");
int a6=rs.getInt("a6");
int a7=rs.getInt("a7");
int a8=rs.getInt("a8");
int a9=rs.getInt("a9");
int a10=rs.getInt("a10");
int a11=rs.getInt("a11");%>
<table width="71%" height="380" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>调查结果:</td>
<td width="80%" height="20" align="left"> 总共:<span class="STYLE1">
<%=rs.getInt("num")%></span>人参加投票</td>
<td width="8%" align="right"> </td>
</tr>
<tr>
<td height="20" colspan="3">1.您认为我这人好吗?:</td>
</tr>
<tr>
<td width="12%">
好</td>
<td height="20" colspan="2"><img src="vb.gif" width=<%=a1%> height="10" /></td>
</tr>
<tr>
<td>不好</td>
<td height="20" colspan="2">
<img src="vb.gif" width=<%=a2%> height="10" /></td>
</tr>
<tr>
<td>不知道</td>
<td height="20" colspan="2"><img src="vb.gif" width=<%=a3%> height="10" /></td>
</tr>
<tr>
<tr>
<td height="20" colspan="3">2.您觉得你很了解我吗?:</td>
</tr>
<tr>
<td>是</td>
<td height="20" colspan="2"><img src="vb.gif" width=<%=a4%> height="10" /></td>
</tr>
<tr>
<td>否</td>
<td height="20" colspan="2">
<img src="vb.gif" width=<%=a5%> height="10" /></td>
</tr>
<tr>
<td height="20" colspan="3">3.您认为我们的关系:</td>
</tr>
<tr>
<td>好</td>
<td height="20" colspan="2">
<img src="vb.gif" width=<%=a6%> height="10" /></td>
</tr>
<tr>
<td>一般</td>
<td height="20" colspan="2">
<img src="vb.gif" width=<%=a7%> height="10" /></td>
</tr>
<tr>
<td>不好</td>
<td height="20" colspan="2">
<img src="vb.gif" width=<%=a8%> height="10" /></td>
</tr>
<tr>
<td>不知道</td>
<td height="20" colspan="2">
<img src="vb.gif" width=<%=a9%> height="10" /></td>
</tr>
<tr>
<td height="20" colspan="3">4.您是否希望我们的关系再好一点吗:</td>
</tr>
<tr>
<td height="17">是</td>
<td height="20" colspan="2">
<img src="vb.gif" width=<%=a10%> height="10" /></td>
</tr>
<tr>
<td height="18">否</td>
<td height="20" colspan="2">
<img src="vb.gif" width=<%=a11%> height="10" /></td>
</tr>
<tr>
<td height="9" colspan="3" align="left" class="STYLE1">。。。。。。。。。。。。K中心制作。。。。。。。。。。。。。。。</td>
</tr>
<tr>
<td height="47" colspan="3" align="center" class="STYLE1"><a href="javascript:window.close()">关闭窗口</a></td>
</tr>
</table><%}
}
catch (SQLException e) {
out.print("SQL Exception occur. Message is:");
out.print(e.getMessage());
}%>
<%
rs.close();
stmt.close();
con.close();
%>//这里他说错了!
</body>
</html>
500 Servlet Exception
/01/show.jsp:135: cannot resolve symbol
symbol : variable rs
location: class _jsp._01._show__jsp
rs.close();
^
/01/show.jsp:136: cannot resolve symbol
symbol : variable stmt
location: class _jsp._01._show__jsp
stmt.close();
^
/01/show.jsp:137: cannot resolve symbol
symbol : variable con
location: class _jsp._01._show__jsp
con.close();
^
3 errors