MySql创建链接失败?????

xzg 发布于 2009/09/23 08:28
阅读 948
收藏 0
org.apache.jasper.JasperException: java.lang.RuntimeException: java.lang.RuntimeException: 
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.ConnectException
MESSAGE: Connection refused: connect

STACKTRACE:

java.net.ConnectException: Connection refused: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
	at java.net.Socket.connect(Socket.java:519)
	at java.net.Socket.connect(Socket.java:469)
	at java.net.Socket.<init>(Socket.java:366)
	at java.net.Socket.<init>(Socket.java:209)
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)
	at com.mysql.jdbc.Connection.createNewIO(Connection.java:2744)
	at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
	at java.sql.DriverManager.getConnection(DriverManager.java:582)
	at java.sql.DriverManager.getConnection(DriverManager.java:185)
	at org.apache.jsp.admin.createHtmlMgr.createChannel_jsp._jspService(createChannel_jsp.java:70)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.SessionCheck.doFilter(SessionCheck.java:35)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.saas.biz.commen.cookiesMgr.doFilter(Unknown Source)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
	at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
	at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769)
	at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698)
	at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
	at java.lang.Thread.run(Thread.java:619)


** END NESTED EXCEPTION **



Last packet sent to the server was 0 ms ago.
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	

各位帮帮忙,这个问题一般是什么问题呀?

加载中
0
红薯
红薯

这个问题很明显是无法连接到 MySQL 的问题,跟代码应该是没关系的

需要检查的内容:

1. 用户名口令是否正确
2. MySQL主机地址和端口是否正确

可以尝试在程序运行的同一台机器上用其他的MySQL客户端连着试试看

0
t
try__again

如果mysql和程序不再同一台机器上,还要考虑mysql是否允许远程登录的问题

0
xzg
xzg

引用来自“红薯”的帖子

这个问题很明显是无法连接到 MySQL 的问题,跟代码应该是没关系的

需要检查的内容:

1. 用户名口令是否正确
2. MySQL主机地址和端口是否正确

可以尝试在程序运行的同一台机器上用其他的MySQL客户端连着试试看

 我试过的,不是那个原因,用户名和我密码都是正确的,这个现象是一阵儿一阵儿的,在我的那个程序里面,和数据库连接的时间比较长...

得遍历数据库里面的一张表里面的全部数据,所以很耗时间...

之前还没出现过这样的问题,现在不知道怎么回事儿....谢谢哥了,谢谢

0
polly
polly

连接被拒绝,一般是网络不通,从客户机telnet数据库的3306端口,并检查防火墙;

从你的描述来看,偶尔不行,猜测可能是超过连接数了吧,你没用连接池吧?

创建了连接是不是没有释放?

无法登陆的情况下,在客户机上,netstat |grep 数据库IP,看多少个连接?

0
xzg
xzg

引用来自“polly”的帖子

连接被拒绝,一般是网络不通,从客户机telnet数据库的3306端口,并检查防火墙;

从你的描述来看,偶尔不行,猜测可能是超过连接数了吧,你没用连接池吧?

创建了连接是不是没有释放?

无法登陆的情况下,在客户机上,netstat |grep 数据库IP,看多少个连接?

 你好,我用的是windows2003.似乎是连接数太多了

返回顶部
顶部