title: Connect to mysql database java
body: <p>I am trying to connect to MySQL database from Java (MySQL is hosted in WAMP server)</p>
  
  <pre><code>String userName = "root";
  String password = "pass";
  String url = "jdbc:mysql://localhost/dbase";
  Class.forName ("com.mysql.jdbc.Driver").newInstance ();
  conn = DriverManager.getConnection (url, userName, password); 
  </code></pre>
  
  <p>The connection is fine when I am running from localhost. However when I run this code from another computer replacing localhost with my computer's IP (within the same network), I get the error, </p>
  
  <pre><code>message from server: "Host '&lt;name&gt;' is not allowed to connect to this MySQL server"
  </code></pre>
  
  <p>I have tried with port 3306 too. Whats wrong?</p>