title: GWT Problem with MySQL Connection
body: <p>I am working on a GWT project in which I need to make some MySQL queries. I have handled RPC properly and in the server-side I am trying to make a mysql connection but am running into an exception: </p>
  
  <p>com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:112)
      at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:120)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
      at com.mysql.jdbc.Util.getInstance(Util.java:386)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
      at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2412)
      at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)
      at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:792)
      at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:112)
      at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:120)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
      at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
      at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
  .
  .
  .
  more
  .
  .
  .</p>
  
  <p>I created a very simple java class to test out my code to confirm that my connection syntax and use is proper, and have confirmed that syntax is not a problem because with the very same code in a simple only main method java app I can create a connection and query the database properly. I have made sure to have mysql-connector-java-5.1.16-bin.jar in the classpath as well as the /lib folder in the WEB-INF folder.</p>
  
  <p>Here is the class that I am using in order to create a connection:</p>
  
  <p>public class DB_Connection {</p>
  
  <p>protected Connection getConnection() {
        Connection conn = null;
        try {
           Class.forName("com.mysql.jdbc.Driver").newInstance();
           conn = DriverManager.getConnection("jdbc:mysql:///",
                                              "", 
                                              "");<br>
        }
        catch (Exception ex)
        {
           ex.printStackTrace();
        }</p>
  
  <pre><code>  return conn;
  </code></pre>
  
  <p>}</p>
  
  <p>}</p>
  
  <p>public class Login extends DB_Connection {</p>
  
  <p>public User getUser(String email) {
        User user = new User();
        user.setUserEmail(email);
        String query = "";</p>
  
  <pre><code>  try {
       Connection conn = getConnection();
       Statement statement = conn.createStatement();
       ResultSet result = statement.executeQuery(query);
       while(result.next()) {
          user.setUserId(result.getInt("rvuser_id"));
          System.out.println(user.getUserId());
       }
    }
    catch (Exception ex)
    {
       ex.printStackTrace();
    }
  
    return user;
  </code></pre>
  
  <p>}</p>
  
  <p>It seems my problem happens all the way at the beginning in DB_Connection. Does anyone know what is making this happen? It is strange to me, because as a standalone the code works fine.</p>
  
  <p>Another thing I just realized that I am at home now and don't even have access to that database server as it is on a local network and I am not connected through VPN. So it must be failing somehow before it even attempts to make the connection.</p>
  
  <p>Thanks!</p>