| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3228 人关注过本帖
标题:jsp连接mysql时出现HTTP Status 500 - 高手请进
只看楼主 加入收藏
lulu820830
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2008-3-24
收藏
 问题点数:0 回复次数:1 
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麻烦高手帮忙看一下,是怎么回事
搜索更多相关主题的帖子: jsp mysql HTTP Status 500 - 
2008-08-20 19:06
elan1986
Rank: 6Rank: 6
等 级:贵宾
威 望:18
帖 子:458
专家分:407
注 册:2007-12-17
收藏
得分:0 
org.apache.jasper.JasperException: An exception occurred processing JSP page /test.jsp at line 8
test.jspt页面可能有问题吧!
2008-09-23 11:29
快速回复:jsp连接mysql时出现HTTP Status 500 - 高手请进
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035499 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved