title: java how to connect to a MySQL database in OpenShift
body: <pre><code>package library;
  
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  public class conexion {
  
      private String server = "jdbc:mysql://" + System.getenv("OPENSHIFT_MYSQL_DB_HOST") + ":" + System.getenv("OPENSHIFT_MYSQL_DB_PORT") + "/" + System.getenv("OPENSHIFT_APP_NAME") + "";
      private String user = System.getenv("OPENSHIFT_MYSQL_DB_USERNAME");
      private String pass = System.getenv("OPENSHIFT_MYSQL_DB_PASSWORD");
      private Connection conn;
  
      public Connection conectar() throws ClassNotFoundException, SQLException {
          try {
              Class.forName("com.mysql.jdbc.Driver");
              this.conn = DriverManager.getConnection(server, user, pass);
          } catch (Exception ex) {
              Logger.getLogger(conexion.class.getName()).log(Level.SEVERE, null, ex + ex.getMessage());
          }
  
          return this.conn;
      }
  
  }
  </code></pre>
  
  <p>I have a java application lodged in OpenShift but when I try to connect it to the cartridge mysql nothing happens when you connect. only it stays in the servlet and takes no other action</p>