title: How to connect to a Cloud Foundry MySQL database connection in Java?
body: <p>create mysql as service on Cloud Foundry and tunnel to mysql database 
  this provides me connection string to mysql database i pass that information to my app. 
  it works from my machine but when i deployed that app on Cloud Foundry server then it gives an error in connection </p>
  
  <p>this is my connection code, tell me what needs to change to be deployed on Cloud Foundry</p>
  
  <pre><code>public class DB {
      private static Connection connection = null;
      public static Connection getConnection() {
          String url = "jdbc:mysql://127.0.0.1:10100/db8dad2d02e114ef6bc9d24e68367e33e";
          try {
  
              Class.forName("com.mysql.jdbc.Driver");
              connection = DriverManager.getConnection(url,"uC0ag3NRJCT8c","p1nyZ38zadwfa");
              System.out.println("Connect success fully");
              return connection;
  
          } catch (Exception e) {
              System.out.println("Error");
              System.out.println(e);
              e.printStackTrace();
  
          }
          return null;
  
      }
  
  }
  </code></pre>