日期:2014-05-18  浏览次数:20947 次

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.s