private String sDBDriver = "org.gjt.mm.mysql.Driver
private String sConnStr = "jdbc:mysql://localhost:3306/mytest?user=root&password=system";
Class.forName(sDBDriver);
conn=DriverManager.getConnection(sConnStr);提示错误:
java.lang.NullPointerException
at newsgroup.MysqlConnect.main(MysqlConnect.java:146)
DBConnect():Communication failure during handshake. Is there a server running on localhost:3306?
Exception in thread "main" 我用mysql的客户端连接数据正常。
但是查一下,3306的端口绑定的IP是0.0.0.0,这是为什么,如何解决?

解决方案 »

  1.   

    mysql 的端口是 3306 吗,好像是端口错啦
      

  2.   

    你的MySQL服务器地址没设定还是没有设正确?
      

  3.   

    [client]port=3306[mysql]default-character-set=gbk
    # SERVER SECTION
    # ----------------------------------------------------------------------
    #
    # The following options will be read by the MySQL Server. Make sure that
    # you have installed the server correctly (see above) so it reads this 
    # file.
    #
    [mysqld]# The TCP/IP Port the MySQL Server will listen on
    port=3306如果是默认设置,3306端口是没错的。
      

  4.   

    "jdbc:mysql://localhost:3306/mytest?user=root&password=system";//localhost --〉替换为ip 地址 或者 127.0.0.1
      

  5.   

    搞定了,我把mysql的驱动升到5.0就好使了。