标题:[求助] 我的mysql和jsp怎么连不上?
只看楼主
fengxfu
Rank: 1
等 级:新手上路
帖 子:180
专家分:0
注 册:2006-7-22
得分:0 
我刚才把Tomcat 5.0\common\lib下的mysql驱动mysql-connector-java-3.1.11-bin.jar删了.然后运行时,抛出异常,在页面的最上边写了一句英文,意思是没找到驱动.

可是当我在把mysql-connector-java-3.1.11-bin.jar在放回去时,又是如下提示(以前没见过这种提示,整个页面只是这些):


com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.SocketException MESSAGE: java.net.ConnectException: Connection refused: connect STACKTRACE: java.net.SocketException: java.net.ConnectException: Connection refused: connect at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156) at com.mysql.jdbc.MysqlIO.(MysqlIO.java:284) at com.mysql.jdbc.Connection.createNewIO(Connection.java:2541) at com.mysql.jdbc.Connection.(Connection.java:1474) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266) at java.sql.DriverManager.getConnection(DriverManager.java:525) at java.sql.DriverManager.getConnection(DriverManager.java:171) at org.apache.jsp.mysql.mysql_jsp._jspService(mysql_jsp.java:55) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:595) ** END NESTED EXCEPTION ** Last packet sent to the server was 0 ms ago.

我靠~~问题多得很!
2006-09-10 00:36
fengxfu
Rank: 1
等 级:新手上路
帖 子:180
专家分:0
注 册:2006-7-22
得分:0 
版主和球球快帮我看看吧..我都快风了..................

我靠~~问题多得很!
2006-09-10 00:38
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
得分:0 
11楼的异常是说数据库套接字连接失败,这次100%是数据库连接问题。
重启你的程序
然后再次按照7楼的方法检查

淘宝杜琨
2006-09-10 07:50
球球
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:1146
专家分:265
注 册:2005-11-28
得分:0 
我的意思是你好好检查你jsp文件里的那两个地方,不是这两句的什么问题,这两句当然看不到啦.
再不把数据库连接的代码贴上来呀.

好累
2006-09-10 15:10
fengxfu
Rank: 1
等 级:新手上路
帖 子:180
专家分:0
注 册:2006-7-22
得分:0 

这是原文件,大家看一下.


<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>

<html>
<body>
<%
String sDBDriver="com.mysql.jdbc.Driver";
String sConnStr="jdbc:mysql://localhost:3306/chen";
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
try{
Class.forName(sDBDriver);
con=DriverManager.getConnection(sConnStr,"root","chenxfu");
stmt=con.createStatement();
rs=stmt.executeQuery("select * from book");
while(rs.next()){
out.println(""+rs.getString(1)+"");
out.println(":"+"<br>");
out.println(rs.getString(2));
out.println(rs.getString(3));
}
rs.close();
}
catch(Exception e){
out.println(e);
}
%>
</body>
</html>


我靠~~问题多得很!
2006-09-10 20:14
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
得分:0 

写在main程序里 看看能不能编译


win32汇编
病毒 加密
目前兴趣所在
2006-09-10 20:27
fengxfu
Rank: 1
等 级:新手上路
帖 子:180
专家分:0
注 册:2006-7-22
得分:0 
以下是引用韩峰在2006-9-10 20:27:34的发言:

写在main程序里 看看能不能编译

什么意思呢?? 我不懂,说明白一点吧..谢谢了


我靠~~问题多得很!
2006-09-10 21:07
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
得分:0 
随手写的 有语法错误你改改
public class TestDb
{
public static void main(String [] args)
{
String sDBDriver="com.mysql.jdbc.Driver";
String sConnStr="jdbc:mysql://localhost:3306/chen";
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
try{
Class.forName(sDBDriver);
con=DriverManager.getConnection(sConnStr,"root","chenxfu");
stmt=con.createStatement();
rs=stmt.executeQuery("select * from book");
while(rs.next()){
System.out.println(""+rs.getString(1)+"");
System.out.println(":"+"<br>");
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
}
rs.close();
}
catch(Exception e){
System.out.println(e);
}
}
}

win32汇编
病毒 加密
目前兴趣所在
2006-09-10 22:19
球球
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:1146
专家分:265
注 册:2005-11-28
得分:0 
mysql我不太熟悉,但加载驱动好像这样也可以吧?
Class.forName("org.gjt.mm.mysql.Driver").newInstance();

好累
2006-09-10 22:40
fengxfu
Rank: 1
等 级:新手上路
帖 子:180
专家分:0
注 册:2006-7-22
得分:0 

先谢谢各位了,我现在真的是无言了. 没连上,还是先放一段时间吧.这样下去我肯定会疯.谢谢各位的帮助!~~


我靠~~问题多得很!
2006-09-10 23:14



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-88818-1-1.html




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

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