jsp连接mysql时出现HTTP Status 500 - 高手请进
我的源程序是: <%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.sql.*"%>
<html>
<body>
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/jsptest?user=***&password=***&useUnicode=true&characterEncoding=GBK" ;
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
String query="select * from t";
ResultSet rs=stmt.executeQuery(query);
while(rs.next())
{
String s=rs.getString("field_name");//字段不是字符型的话就不能用getString,根据字段类使用getBoolean等等
int i=rs.getInt("v");
out.println(s+" "+i+" <br>");
}
%>
</body>
</html>
出现下面的错误提示:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /test.jsp at line 8
5: <%
6: Class.forName("org.gjt.mm.mysql.Driver").newInstance();
7: String url ="jdbc:mysql://localhost/jsptest?user=***&password=***&useUnicode=true&characterEncoding=GBK" ;
8: Connection conn= DriverManager.getConnection(url);
9: Statement stmt=conn.createStatement();
10: String query="select * from t";
11: ResultSet rs=stmt.executeQuery(query);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: com.mysql. Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
MESSAGE: Connection refused: connect
STACKTRACE:
Connection refused: connect
at (Native Method)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at (Unknown Source)
at <init>(Unknown Source)..........
我刚学jsp和mysql麻烦高手帮忙看一下,是怎么回事