你的url好像不太对啊:jdbc:mysql://localhost?user=root&password=root 其中少了端口和数据库的名称。
试用一下这个
jdbc:mysql://localhost:3306/databasename?user=root&password=root

解决方案 »

  1.   

    应该是这样的吧
    Class.forName("com.mysql.jdbc.Driver");
    String url = "jdbc:mysql://127.0.0.1/databaseName,user,password";
    Connection con = DriverManager.getConnection(url);
      

  2.   

    String url = "jdbc:mysql://localhost?user=root&password=root";
    ----此行少了指定database name, 故错误中报了"java.sql.SQLException: No database selected
      

  3.   

    No database selected已经很清楚了,看来英文要加强