title: Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "OPENSHIFT_MYSQL_DB_PORT"'
body: <p>I am trying to deploy my Jersey project on openshift. I have implemented this apple class to test the error in the another class since I guess the problem is with the establishing the database connection. in the Tails log I found this error:</p>
  
  <blockquote>
    <p>Connecting to databaseâ€¦
    com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "OPENSHIFT_MYSQL_DB_PORT"'.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)</p>
  </blockquote>
  
  <pre><code>package org.busTracker.serverSide;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  /**
   * Root resource (exposed at "myresource" path)
   */
  @Path("myresource")
  public class Apple {
  
     //I modified my credients.
      String host = "jdbc:mysql://$OPENSHIFT_MYSQL_DB_HOST:OPENSHIFT_MYSQL_DB_PORT/serverside";
      String user = "adminBjv5a4k";
      String password = "7tvPb1Bx3v8j";
  
      /**
       * Method handling HTTP GET requests. The returned object will be sent
       * to the client as "text/plain" media type.
       *
       * @return String that will be returned as a text/plain response.
       */
      @GET
      @Produces(MediaType.TEXT_PLAIN)
      public String getIt() {
  
          Connection conn = null;  
          try {    
            Class.forName("com.mysql.jdbc.Driver");    
            System.out.println("Connecting to database…");    
            conn = DriverManager.getConnection(host,user,password);    
          } catch (Exception e) {    
            e.printStackTrace();    
          } finally {    
            if (conn != null) {    
              try {    
                conn.close();    
              } catch (SQLException e) {    
                // ignore    
              }    
            }    
          }   
  
          return "Hello, from apple class   14.05.15 11:35!";
      }
  
  }
  </code></pre>
  
  <p><strong>Edit:</strong> I added the following to the try block after DriverManager.getConnection():</p>
  
  <pre><code>  Map&lt;String, String&gt; env = System.getenv();
    for (String envName : env.keySet()) {
        System.out.format("%s=%s%n",
                          envName,
                          env.get(envName));
    }
  </code></pre>
  
  <p>I have tried the following but I am still getting the same error:</p>
  
  <ul>
  <li>This solution: <a href="https://forums.openshift.com/mysql-51-jboss-app-numberformatexception-mysql-url" rel="nofollow">https://forums.openshift.com/mysql-51-jboss-app-numberformatexception-mysql-url</a> And add the following jdbc:mysql://${env.OPENSHIFT_MYSQL_DB_HOST}:${env.OPENSHIFT_MYSQL_DB_PORT}/serv‌​erside but nothing changed.</li>
  <li>"jdbc:mysql://127.10.310.130:3306 /serverside"; This values are from the phpmyadmin of the app.</li>
  </ul>