jsp连接mysql数据库报错,cmd窗口进去可以连接数据库
报错具体代码:org.apache.jasper.JasperException:AnexceptionoccurredprocessingJSPpage/connect...
报错具体代码:
org.apache.jasper.JasperException: An exception occurred processing JSP page /connect.jsp at line 16
16: Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookDB","root","root");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
javax.servlet.ServletException: java.sql.SQLException: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream
下面还有一段nested exception省略,字数不够了,之前觉得可能是驱动包的问题,已经安装驱动包到各种bin文件夹下,可是都没有作用,完全看不出出了什么问题,求指导~ 展开
org.apache.jasper.JasperException: An exception occurred processing JSP page /connect.jsp at line 16
16: Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookDB","root","root");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
javax.servlet.ServletException: java.sql.SQLException: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream
下面还有一段nested exception省略,字数不够了,之前觉得可能是驱动包的问题,已经安装驱动包到各种bin文件夹下,可是都没有作用,完全看不出出了什么问题,求指导~ 展开
1个回答
展开全部
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/bookDB";
String user = "root";
String pass = "root";
Connection con = DriverManager.getConnection(url, user, pass);
你试一下
追问
试过了,没用,一直都是getConnection这一行报错,我想会不会是驱动包版本问题啊,我这边是mysql-connector-java-5.1.7-bin.jar
追答
我的..
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询