首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

jdbc联接MYSQL数据库不成功,牛人过来给看看

2013-09-11 
jdbc连接MYSQL数据库不成功,牛人过来给看看HTTPStatus500-typeExceptionreportmessagedescriptionTheserve

jdbc连接MYSQL数据库不成功,牛人过来给看看
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:   Exception   in   JSP:   /jdbc.jsp:15

12:                   String   user= "root ";
13:                   String   passw= " ";
14:                   Class.forName( "com.mysql.jdbc.Driver ").newInstance();
15:                   conn=DriverManager.getConnection(url,user,passw);
16:                  
17:                   Statement   stmt=conn.createStatement();
18:                   ResultSet   rs=stmt.executeQuery( "select   *   from   animalInfo ");


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root   cause  
javax.servlet.ServletException:   Communications   link   failure   due   to   underlying   exception:  

**   BEGIN   NESTED   EXCEPTION   **  

java.net.SocketException
MESSAGE:   java.net.ConnectException:   Connection   refused

STACKTRACE:

java.net.SocketException:   java.net.ConnectException:   Connection   refused
at   com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
at   com.mysql.jdbc.MysqlIO. <init> (MysqlIO.java:276)
at   com.mysql.jdbc.Connection.createNewIO(Connection.java:2666)
at   com.mysql.jdbc.Connection. <init> (Connection.java:1531)
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.jdbc_jsp._jspService(jdbc_jsp.java:58)
at   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)


at   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at   org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at   org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at   org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at   org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at   java.lang.Thread.run(Thread.java:595)


**   END   NESTED   EXCEPTION   **


Last   packet   sent   to   the   server   was   21   ms   ago.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.jdbc_jsp._jspService(jdbc_jsp.java:121)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root   cause  
com.mysql.jdbc.CommunicationsException:   Communications   link   failure   due   to   underlying   exception:  

**   BEGIN   NESTED   EXCEPTION   **  

java.net.SocketException
MESSAGE:   java.net.ConnectException:   Connection   refused

STACKTRACE:

java.net.SocketException:   java.net.ConnectException:   Connection   refused
at   com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
at   com.mysql.jdbc.MysqlIO. <init> (MysqlIO.java:276)
at   com.mysql.jdbc.Connection.createNewIO(Connection.java:2666)
at   com.mysql.jdbc.Connection. <init> (Connection.java:1531)
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.jdbc_jsp._jspService(jdbc_jsp.java:58)
at   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)


at   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at   org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at   org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at   org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at   org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at   java.lang.Thread.run(Thread.java:595)


**   END   NESTED   EXCEPTION   **


Last   packet   sent   to   the   server   was   21   ms   ago.
com.mysql.jdbc.Connection.createNewIO(Connection.java:2741)
com.mysql.jdbc.Connection. <init> (Connection.java:1531)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
java.sql.DriverManager.getConnection(DriverManager.java:525)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.jdbc_jsp._jspService(jdbc_jsp.java:58)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note   The   full   stack   trace   of   the   root   cause   is   available   in   the   Apache   Tomcat/5.5.17   logs.
Apache   Tomcat/5.5.17

[解决办法]
超出连接数?
[解决办法]
用mysql client连mysql正常吗?
[解决办法]
mysql驱动包放了吗?
[解决办法]
url定义在哪儿?
[解决办法]
1,先检查URL对不对
2,检查驱动
3,用mysql客户端连接数据库验证数据库是否正常
4,如果还不行,继续到CSDN发帖
—————— 菜鸟的胡说八道
[解决办法]
JSP连接MySQL数据库代码

http://www.java99.com/?m=ViewArticle&id=254
[解决办法]
在创建Mysql数据库时,是否给这个数据库分配了用户权限。
[解决办法]
数据库 不正常
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行