Please help me, I have no idea how to connect with cloud sql on eclipse !!

350 views
Skip to first unread message

심건우

unread,
Jun 5, 2018, 9:03:13 AM6/5/18
to Google Cloud SQL discuss

Here is code and error message


<code>

package com.google.cloud.sql.mysql.conv;

import java.io.IOException;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

 

public class HelloAppEngine {

  public static void main(String[] args) throws IOException, SQLException {

   String instanceConnectionName = "convenience-205510:asia-east1:convenience";

    String databaseName = "conv";

    String username = "root";

    String password = "";

 

    //[START doc-example]

    String jdbcUrl = String.format(

        "jdbc:mysql://google/%s?cloudSqlInstance=%s"

            + "&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false",

        databaseName, instanceConnectionName);

     Connection connection = DriverManager.getConnection(jdbcUrl, username, password);

   //[END doc-example]

    try (Statement statement = connection.createStatement()) {

      ResultSet resultSet = statement.executeQuery("SHOW TABLES");

      while (resultSet.next()) {

        System.out.println(resultSet.getString(1));

      }

    }

  }

}


<error message>

Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:mysql://google/conv?cloudSqlInstance=convenience-205510:asia-east1:convenience&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false

at java.sql/java.sql.DriverManager.getConnection(Unknown Source)

at java.sql/java.sql.DriverManager.getConnection(Unknown Source)

at com.google.cloud.sql.mysql.conv.HelloAppEngine.main(HelloAppEngine.java:21)


How can i solve this problem ??


1.PNG
2.PNG

Jordan (Cloud Platform Support)

unread,
Jun 5, 2018, 2:15:12 PM6/5/18
to Google Cloud SQL discuss
Make sure you have the proper dependencies in your pom.xml as shown in the documentation, and have set '<service>cloudsql</service>' in your appengine-web.xml. Also performing a 'mvn clean' before deploying is recommended. 

Since this not a Google error and is a common Java issue, I would recommend reviewing the existing troubleshooting guides that already exist on Stack Exchange. 

- Note, Google Groups is reserved for general product discussions and is not for technical support. If you require further support for getting your application to run, it is recommended to post your detailed questions to Stack Exchange using the supported Cloud tags. 
Reply all
Reply to author
Forward
0 new messages