JSP怎么和MYSQL数据库连接?

我按网上说的配置后运行后显示如下,请高手指教一下!!typeExceptionreportmessagedescriptionTheserverencounteredan... 我按网上说的配置后运行后显示如下,请高手指教一下!!
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.sql_jsp._jspService(sql_jsp.java:127)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.sql_jsp._jspService(sql_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
希望能帮我看出是哪里出错,高手请加QQ:190961293,感激不尽!!!
展开
 我来答
racnow
2008-04-28 · 超过36用户采纳过TA的回答
知道答主
回答量:127
采纳率:0%
帮助的人:0
展开全部
这不是连My SQL吧,你连的是SQL Server吧,看错误提示“Error establishing socket. ”,SQL Server的sp3补丁没装,自己取找一个装了就ok了。
__________________________
还没给分啊,不用怀疑,绝对是补丁问题
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
这个错误谁要说不是补丁问题你帮我揍他
百度网友7ec2af9f
2008-04-28 · TA获得超过113个赞
知道小有建树答主
回答量:196
采纳率:0%
帮助的人:90.5万
展开全部
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" import="java.util.Vector" errorPage="" %>
<!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>
</head>
<%
request.setCharacterEncoding("gb2312");
response.setCharacterEncoding("gb2312");
String id=request.getParameter("id");

Connection con= null;//创建链接
Statement stmt= null;//创建对象

try{
Class.forName("com.mysql.jdbc.Driver");//加载驱动包
String url ="jdbc:mysql://localhost:3306/xnwxt?user=root&password=87601401&useUnicode=true&characterEncoding=GB2312";
con =DriverManager.getConnection(url);//得到链接
stmt=con.createStatement();//创建链接

String delete1="delete from xnwxt where id='"+id+"' ";

stmt.executeUpdate(delete1);//执行删除语句

response.sendRedirect("ywl.jsp");//返回另外一个页面

con.close();//关闭链接
stmt.close();//关闭对象

}catch(SQLException sqle){
out.println("sqle="+sqle);
}finally{
try{
if(con!=null){
con.close();
}
}catch (SQLException sqle){
out.println("sqle="+sqle);
}
}

%><body>
</body>
</html>
这是我的MYSQL 删除 数据的例子 里面含有和Mysql链接,你自己看一下
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
xiongdamao
2008-04-28 · 超过14用户采纳过TA的回答
知道答主
回答量:42
采纳率:0%
帮助的人:0
展开全部
mysql没有启动
在防火墙打开3306端口
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式