myeclipse中运行jsp报错,求解
基本环境已搭建好,用的是mysql-connector-java-5.1.17-bin.jar
<%@ page language="java" import="java.sql.*" pageEncoding="gb2312"%>
<%
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String url = null;
String user = null;
String password = null;
try
{
Class.forName("com.myqsl.jdbc.Driver");
url = "jdbc:mysql://localhost:3306/suifeng";
user = "root";
password = "root";
conn = DriverManager.getConnection (url,user,password);
stmt = conn.createStatement();
String query = "select * from user_info";
rs = stmt.executeQuery(query);
%>
<html>
<head>
<title>JSP使用JDBC链接MySQL</title>
</head>
<body>
<table border=1 cellpadding=0 cellspacing=0>
<tr bgcolor=gray>
<td>FirstName</td>
<td>LastName</td>
<td>NickName</td>
</tr>
<%
while (!rs.isLast())
{
rs.next();
%>
<tr>
<td><%=rs.getString("first_name") %></td>
<td><%=rs.getString("last_name") %></td>
<td><%=rs.getString("nick_naem") %></td>
</tr>
<%
}
}
catch(Exception e)
{
}
finally
{
rs.close();
stmt.close();
conn.close();
}
%>
</table>
</body>
</html>
报的错误是:
org.apache.jasper.JasperException: Exception in JSP: /simpleDBAccess.jsp:59
56: }
57: finally
58: {
59: rs.close();
60: stmt.close();
61: conn.close();
62: }
这是什么意思呢?
------解决方案--------------------rs在进行关闭时得判断一下(rs!=null),个人觉得rs应该是null了,在关闭rs, stmt, conn时还得捕获异常。LZ最好把所有的异常信息都贴出来,那样有助于解决问题
------解决方案--------------------"com.myqsl.jdbc.Driver" 写错了。