1

I want to connect to the Google Cloud SQL from my android app. Is there a way to do this without the App Engine and Endpoints? If this does not exist, please tell me the most painless way to solve this problem. I'm just in the future does not intend to use the App Engine, and therefore do not understand why waste time on it.

Irvin Bridge
  • 303
  • 5
  • 11
  • 7
    As a general comment, unrelated to specific technologies, it would be relatively odd to talk *directly* to your database from an external application. Back in the days of an intranet it was reasonably common, but now a more modern approach is to design the API you want your application to use, then implement a web service which talks to the database. You can then change databases, even cloud providers, with much less upheaval. – Jon Skeet Jun 24 '16 at 15:24
  • 2
    Also, talking directly means that you'll provide all keys with you android app. Do you want to see how bunch of spammers are utilizing your GCP account instead of you? – Igor Artamonov Jun 24 '16 at 15:41
  • See: http://stackoverflow.com/questions/26470117/can-we-connect-remote-mysql-database-in-android-using-jdbc. If you disilke App Engine, maybe consider Firebase. – Bill Prin Jun 24 '16 at 20:24

1 Answers1

2

I have actually used Google Cloud SQL with App Engine + Endpoints (Java) so I can weigh in here a little.

You can create a helper class in App Engine and easily connect to Google Cloud SQL. Then, you can create endpoint methods that take in some parameters and inside the method access Cloud SQL and perform some operations securely.

This is highly advisable against interacting with your Cloud SQL database in the Android client app because that is a big security risk. If someone decompiles your app somehow, they now have full access to your database credentials.

If you have not a very large app you can use the above approach. But honestly, I would just the time to learn GAE Datastore and use that instead or Firebase. SQL can run into issues if your app gets big but maybe you aren't trying to build the next huge app so it will suffice. It all depends on you.

Hope that helps.

Micro
  • 10,303
  • 14
  • 82
  • 120