Written by Alistair Sykes
Mar 08, 2018

Setting up Cloud SQL in Java

Are you setting up Cloud SQL within a Java project using Android Studio? Read on - and hopefully we can point you in the right direction!

Cloud SQL

Cloud SQL is a fully-managed database service. It makes it easy to set up, maintain, manage and administer your relational MySQL database in the cloud: https://cloud.google.com/sql/

The big switch

To set up our database we used a database management application for the easy interface (https://www.sequelpro.com/). I’m sure you’ll have your favourite way of setting up SQL databases. To interact with the database you need a connection:

Gradle dependency

compile 'com.google.cloud.sql:mysql-socket-factory:1.0.4'​

A convenient util method

Appengine-web.xml

Once you have your database connection you can then perform operations utilising the standard Java APIs. We used it in combination with Google Cloud Endpoints. For more information on Cloud Endpoints take a look here. For example:

Next Post

User Authentication for Cloud SQL

Previous Post

Using Google Cloud Endpoints