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,感激不尽!!! 展开
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,感激不尽!!! 展开
3个回答
展开全部
这不是连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)
这个错误谁要说不是补丁问题你帮我揍他
__________________________
还没给分啊,不用怀疑,绝对是补丁问题
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)
这个错误谁要说不是补丁问题你帮我揍他
展开全部
<%@ 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链接,你自己看一下
<!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链接,你自己看一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
mysql没有启动
在防火墙打开3306端口
在防火墙打开3306端口
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询