title: java SQL connection refused exception
body: <p>I am newbie to java db coding...</p>
  
  <p>This is my java code</p>
  
  <pre><code>Connection conn = null;
  Statement stmt = null;
  Class.forName("com.mysql.jdbc.Driver");
  System.out.println("Connecting to database...");
  conn = DriverManager.getConnection("jdbc:mysql://localhost/EMP",USER,PASS);
  System.out.println("Creating statement...");
  stmt = conn.createStatement();
  String sql;
  </code></pre>
  
  <p>This is the exception I am getting : </p>
  
  <pre><code>ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/tiles].[default]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet default threw exception: java.net.ConnectException: Connection refused: connect
  </code></pre>
  
  <p>I am mySQL server also running and contains simple table named EMP. I am not interpreting the get connection URL comppletely. Can anyone explain it briefly?</p>
  
  <p>Thanks.</p>