我在配置好Mysql驱动之后进行getConnection,驱动加载都正确,Mysql启动没问题,数据库、用户名和密码也都没错,可为什么总是会出现下列错误?
Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream ** BEGIN NESTED EXCEPTION ** java.io.IOException MESSAGE: Unexpected end of input stream STACKTRACE: java.io.IOException: Unexpected end of input stream at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:1096) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:626) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1562) at com.mysql.jdbc.Connection.(Connection.java:491) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:193) at org.apache.jsp.movie.Dbjsp_jsp._jspService(Dbjsp_jsp.java:75) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at ……………………
……………………(还有好长)
请问是哪里出了问题?谢谢!
JSP程序如下
try
{
//加载驱动程序,下面的代码为加载MySQL驱动程序
Class.forName("com.mysql.jdbc.Driver").newInstance();
//注册MySQL 驱动程序
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
//用适当的驱动程序连接到数据库
String dbUrl="jdbc:mysql://localhost:3306/movie?user=root&password=admin&useUnicode=true&charsetEncoding=GB2312";
//建立数据库连接
con=DriverManager.getConnection(dbUrl);
 //关闭连接
 con.close();
}
  //捕获错误信息
catch(Exception e){out.println(e.getMessage());}

解决方案 »

  1.   

    url 写简单一点看看 先把编码的部分去掉jdbc:mysql://localhost:3306/movie?user=root&password=admin
      

  2.   

    就是con=DriverManager.getConnection(dbUrl);出的错!
      

  3.   

    jdbc:mysql://localhost:3306/movie?user=root&password=admin
    也不可以
      

  4.   


    the first type you use the old version of the mysql driver;
    the second, your application reuse the connection which has been closed some where.刚刚去IBM论坛查了一下原因
    1.版本太低
    2.利用已关闭connection你看看你的程序和驱动 里面有没有类似情况
      

  5.   

    可能是你的现在分配的ip和你当初安装mysql时的ip不一至。你可以去看看mysql.ini里的#bind-address=192.168.*.*会不会一至,如果不一至把ip mysql.ini里的#bind-address=192.168.*.* 试试看。