I cannot connect to my database thru Compute Engine.
Things I have done so far:
- Setup my Compute Engine
- Connect my Compute Engine to my Cloud SQL
- Install and run Cloud Proxy on my Compute Engine
- Included the JDBC Jar file on my libs folder
- Created the JDBC Connection string
"jdbc:mysql:///?cloudSqlInstance=&socketFactory=com.google.cloud.sql.mysql.SocketFactory;user=&password=";
- Added dependency on my Gradle file
-implementation fileTree(dir: 'libs', include: ['*.jar'])
-implementation 'com.google.cloud.sql:mysql-socket-factory-connector-j-8:1.1.0'
Here is the stack trace:
W/System.err: java.sql.SQLNonTransientConnectionException: Cannot connect to MySQL server on localhost:3,306. W/System.err: Make sure that there is a MySQL server running on the machine/port you are trying to connect to and that the machine this software is running on is able to connect to this host/port (i.e. not firewalled). Also make sure that the server has not been started with the --skip-networking flag. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) W/System.err: at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73) at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:470) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) W/System.err: at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197) at java.sql.DriverManager.getConnection(DriverManager.java:569) at java.sql.DriverManager.getConnection(DriverManager.java:237) W/System.err: at com.dedase.dedaseconstruction.ui.login.LoginActivity$GetPatientID.doInBackground(LoginActivity.java:150) at com.dedase.dedaseconstruction.ui.login.LoginActivity$GetPatientID.doInBackground(LoginActivity.java:136) at android.os.AsyncTask$2.call(AsyncTask.java:333) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) W/System.err: at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.mysql.cj.protocol.SocketConnection com.mysql.cj.protocol.a.NativeProtocol.getSocketConnection()' on a null object reference at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:980) at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826) W/System.err: at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:456) ... 12 more I/Choreographer: Skipped 58 frames! The application may be doing too much work on its main thread. I/zygote: Do full code cache collection, code=123KB, data=111KB After code cache collection, code=117KB, data=78KB