简体   繁体   English

如何在Android Studio中使用Google端点写入Cloud SQL

[英]How to write to Cloud SQL with Google Endpoints in Android Studio

How do you access Google Cloud SQL (which is a MySQL database) with Google Endpoints in Android Studio? 如何在Android Studio中使用Google Endpoints访问Google Cloud SQL(这是一个MySQL数据库)?

I created a Cloud SQL database in the developers console and I have an android project in Android Studio. 我在开发人员控制台中创建了Cloud SQL数据库,并且在Android Studio中有一个android项目。 I just want to press a button and have whatever I wrote in my EditText to be written to the MySQL database. 我只想按一个按钮,然后将我在EditText中编写的内容写入MySQL数据库。 Everywhere I read on Google it says "Use Google Endpoints!" 我在Google上到处阅读的内容都显示“使用Google端点!”。 But it really provides no details on how you actually do this... 但实际上并没有提供有关如何实际执行此操作的详细信息...

I understand Android Studio has support for all these Google Cloud Platform services but I cannot for the life of me find a tutorial or guide on how to do something so simple as I described above. 我了解Android Studio支持所有这些Google Cloud Platform服务,但我终生无法找到有关如何做上述简单操作的教程或指南。

Help! 救命!

The other answer represents some decent sub-components of a potential answer, but I don't agree that there is really a lack in this area of connecting to Cloud SQL. 另一个答案代表了潜在答案的一些体面的子组件,但是我不同意在连接Cloud SQL的领域确实缺乏。 Perhaps on Jul 6, '15 this might have been true, although I don't even think it was then. 也许在15年7月6日,这可能是对的,尽管我什至不认为是那时。 There is a section in the left-hand navigation of the documentation, " Connecting to Instances " which details the various ways to connect to instances. 文档左侧导航栏中有一个“ 连接到实例 ”部分,其中详细介绍了连接到实例的各种方法。

OP, what you need is to send a request to your API handler code, which will then open a connection with the Cloud SQL to perform any actions necessary: OP,您需要向API处理程序代码发送请求,然后该请求将打开与Cloud SQL的连接以执行任何必要的操作:

Client code -> Endpoints code -> Cloud SQL instance

You can read about Cloud Endpoints in the documentation as well. 您也可以在文档中阅读有关Cloud Endpoints的信息。 It's basically a means of writing code which will run and react to a request whenever an API request comes to the back-end server you'll deploy on Google's infrastructure. 基本上,这是一种编写代码的方法,只要API请求到达您要在Google基础架构上部署的后端服务器,它就会运行并对请求做出反应。 These API requests are generally going to be initiated by using a client library, either in JS for the browser, or in Java for Android , etc. 这些API请求通常将通过使用客户端库(在浏览器的JS或Android的Java等)中启动。

There is a major lack in this area, I am currently trying to find answers. 这个领域严重缺乏,我目前正在寻找答案。 It helps to search generally, include examples around servelets. 它有助于进行一般搜索,包括围绕小卷的示例。 This is what I currently have found: 这是我目前发现的:

You have the options of using persistence api's such as JDA and java data objects JDO, which help make things easier, but are developed mainly for the datastore in mind so lack some functionality you might need with relational DB's, such as joins. 您可以选择使用持久性api(例如JDA和Java数据对象JDO),这些选项有助于使事情变得更轻松,但主要是针对数据存储而开发的,因此缺少关系数据库可能需要的某些功能(例如联接)。 Hibernate JPA, DataNucleus JDO/JPA, EclipseLink JPA are the main options. Hibernate JPA,DataNucleus JDO / JPA,EclipseLink JPA是主要选项。

Great example wit JDO JDO的典范

JDBC is a good option for relational databases using Endpoints. 对于使用端点的关系数据库,JDBC是一个不错的选择。 Here is a tutorial(not endpoint specific unfortunately) 这是一个教程(不幸的是,不是特定于端点的)

JDBC example JDBC示例

Google docs example Google文档示例

Will update post as I work things out 我会在处理问题时更新帖子

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

相关问题 如何在Android Studio中的多个项目中重用Google Cloud端点 - How to reuse google cloud endpoints in multiple projects in android studio 使用Android Studio的Google Cloud Endpoints对冒号(:)进行编码 - Encoding of colon (:) with Google Cloud Endpoints, Android Studio Google Cloud端点框架与Android Studio和Gradle 5.1.1不兼容 - Google cloud endpoints framework not compatible with Android studio and gradle 5.1.1 Android Studio Google Cloud Endpoints运行/调试配置错误 - Android Studio Google Cloud Endpoints Run/Debug Config Error 如何使用Android Studio 0.8对Google Cloud Endpoints Java进行单元测试 - How to Unit Test Google Cloud Endpoints Java Using Android Studio 0.8 使用Google Cloud Endpoints的Android应用:数据存储区与SQL - Android app using Google cloud Endpoints: Datastore vs SQL Android Studio:如何设置生成的Cloud Endpoints资源? - Android Studio: how to setup generated Cloud Endpoints sources? 如何将敏感数据从Android应用传递到Google Cloud Endpoints? - How to pass sensitive data to Google Cloud Endpoints from Android app? 如何在Android客户端上访问特定的Google Cloud Endpoints API版本 - How to access specific Google Cloud Endpoints API versions on android clients 将Google Cloud SQL连接到Android Studio项目 - Connect google cloud sql to android studio project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM