jsp连接数据库时报错
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: An exception occurred processing JSP page /ShowArticleTree.jsp at line 14
11: <%
12: Class.forName("com.mysql.jdbc.Driver");
13: String url = "jdbc:mysql://localhost:8080/bbs?user=root&password=root";
14: Connection conn = DriverManager.getConnection(url);
15:
16: %>
17:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handle
JspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.ShowArticleTree_jsp._jspService(ShowArticleTree_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
com.mysql.jdbc.exceptions.jdbc4.
CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago.
The driver has not received any packets from the server. sun.reflect.GeneratedConstructorAccessor6.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:690)
com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1093)
com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2338)
com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
com.mysql.jdbc.Connectio