连不到mysql server,改成:String url="jdbc:mysql://localhost:3306/"+dbName+"?";试试看.

解决方案 »

  1.   

    谢谢 楼上的  不过还是不行 
    我把String url="jdbc:mysql://localhost:3306/"+dbName+"?";改成:url="jdbc:mysql://localhost/webcontrol?user=root&password=admin";
    又可以了  
    请问有什么区别
      

  2.   

    你的mysql登录设了密码,不用密码当然是登录不了啦.
    url="jdbc:mysql://localhost/webcontrol?user=root&password=admin";这一句多了用户名和密码
    你把连接改成用这个连接函数就可以了
    Connection connection=DriverManager.getConnection(url,user,password);