简体   繁体   English

如何连接多用户Android客户端以连接到Google Cloud SQL?

[英]How to connect a multi-user Android client to connect to Google Cloud SQL?

I've been reading through developers.google for a few days now and this process is still confusing me. 我已经阅读了developers.google几天了,这个过程仍然让我感到困惑。

As far as I can tell, I need the following: 据我所知,我需要以下内容:

  • An Android application 一个Android应用程序

  • A Java App-Engine backend that uses Endpoints (still not quite 使用Endpoints的Java App-Engine后端(仍然不完全
    understanding what these are). 了解这些是什么)。

  • Code within this backend that connects to my Cloud SQL instance. 此后端中的代码连接到我的Cloud SQL实例。

My problem is that none of Google's examples seem to have an Android/Cloud-SQL example. 我的问题是Google的示例似乎都没有Android / Cloud-SQL的示例。

I've been using this guide on how to create an Android app with App Engine backend. 我一直在使用本指南来介绍如何使用App Engine后端创建Android应用。 But then it uses Google datastore stuff, I think? 但是我认为它然后使用了Google数据存储的东西吗? I need to use SQL rather than this. 我需要使用SQL而不是这个。

In this guide there is mention of App Engine, but for a JSP web form front-end, and no mention of Endpoints. 本指南中 ,提到了App Engine,但是提到了JSP Web表单前端,没有提到Endpoints。

So my questions boils down to, have I got the right idea with using EndPoints + Cloud SQL, and if yes, how does one achieve this? 因此,我的问题归结为:使用EndPoints + Cloud SQL是否有正确的主意,如果是,请问如何实现这一目标? I'm quite a JDBC newbie in general, so I'm not quite sure how to achieve this off the top of my head. 一般来说,我是JDBC新手,所以我不太确定如何实现这一目标。

you are on the right track. 您走在正确的轨道上。

Just for the record, if you don't have strong reasons (yet) to go for a SQL data store, do consider using Google Data Store as it is better seamlessly integrated into the SDKs and after a couple of compromises it should help you pushing your data design to scale nicer. 仅作记录,如果您还没有充分的理由选择SQL数据存储,请考虑使用Google数据存储,因为它可以更好地无缝集成到SDK中,并且在做出一些妥协之后,应该可以帮助您您的数据设计可以更好地扩展。

Let's split it into parts: 让我们将其分为几部分:

  1. First you have your backend/api. 首先,您拥有后端/ api。 This is basically your piece of code that operates on Google servers, which you'll access on an remote connection basis (http, socket, etc) - (same as most of the APIs we know work). 这基本上是您在Google服务器上运行的代码,您将基于远程连接(http,套接字等)访问这些代码-(与我们知道的大多数API相同)。 I don't know which programming language you are using but here is some basic set up for your project and Cloud SQL on Python. 我不知道您使用的是哪种编程语言,但是这里是针对您的项目和Python上的Cloud SQL的一些基本设置。

  2. Cloud Endpoints is nothing more than a very cool feature that App Engine brought recently to avoid all the mess of creating and updating your client libs over and over again. Cloud Endpoints就是App Engine最近带来的一项非常酷的功能,可以避免一遍又一遍地创建和更新客户端库的麻烦。 It basically automates that task for you, by using annotations or references you put in your backend code to create client libraries for Java, Objective-C and JavaScript that you can then integrate into your clients. 通过使用您在后端代码中添加的注释或引用来创建Java,Objective-C和JavaScript的客户端库,然后可以将其集成到客户端中,它基本上可以为您自动化该任务。

    Example: Let's say I have a controller on my api to operate with bananas, that has a method to delete a banana from the api. 示例:假设我在api上有一个控制器来处理香蕉,该控制器具有从api中删除香蕉的方法。 Annotating that method on your api code, will let endpoints script know that this methods is there to delete bananas, thus it'll gather it and include it in the generated clients libraries, so that you don't have to do that manually for any of your clients, nor every time you update you api code. 在您的api代码上注释该方法,将使终结点脚本知道该方法可以删除香蕉,因此它将收集该方法并将其包含在生成的客户端库中,因此您无需为任何手动操作您的客户,或者每次您更新api代码时。 [Here's] some documentation. [这里]一些文档。

  3. Android Application. Android应用程序。 That's certainly your business :) But I'm sure having your api libs already generated already helps a lot. 那当然是您的事:)但我敢肯定,已经生成您的api库已经很有帮助。

Hope it helps. 希望能帮助到你。 Let me know if you need to get more into detail. 让我知道您是否需要进一步详细说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM