Interaction data between Android client and Java Server (I) Construction of SAE server, androidsae
Usually, the testing server runs on your own PC and is a local server built using Tomcat or IIS. In fact, Sina cloud platform SinaAppEngine is also quite useful. Today I want to summarize some of my usage considerations:
1. Create an SAE application:
Log on to http://sae.sina.com.cn/to register your account. After successful registration, go to "my homepage", Console> Application Management> Create New Application
Enter the second-level domain name (unique application ID), Application name, and other information, and select the development language. Here, Java is used as an example:
Select "Economic edition" for JVM level, 1 for JVM quantity, Dynamic Scaling not selected, and then click "create application ".
After the application is created, you can see it in "Application Management". Click the application title to go to management:
Next, create a version, enter the version number, and upload the code. Java needs to upload the War package:
War package export method:
In Eclipse, right-click the project and choose Export> WAR file.
2. database operations:
Use a visual tool to operate a MySQL database:
Find "Service Management" on the Left bar of the application homepage, click "MySQL", and initialize MySQL first:
Click "manage MySQL" to enter the visual interface. You can also create a table using the SQL language:
SAE databases are divided into master and slave databases for writing and reading respectively.
The display page uses the slave database and the insert page uses the master database. There is a small difference in the URL during connection:
MASTER:
// Use the master database to write data Stringusername = SaeUserInfo. getAccessKey (); Stringpassword = SaeUserInfo. getSecretKey (); Stringdriver = "com. mysql. jdbc. driver "; Class. forName (driver ). newInstance (); Stringurl = "jdbc: mysql: // export rdc.sae.sina.com.cn: 3307/app_bleserver"; Connectioncon = DriverManager. getConnection (url, username, password );
From:
// Use the StringURL = "jdbc: mysql: // r.rdc.sae.sina.com.cn: 3307/app_bleserver"; Stringsql = "select * from message orderby id desc"; StringUsername = SaeUserInfo. getAccessKey (); StringPassword = SaeUserInfo. getSecretKey (); StringDriver = "com. mysql. jdbc. driver "; Class. forName (Driver ). newInstance (); Connectioncon = DriverManager. getConnection (URL, Username, Password );
Reprinted please indicate the source: Zhou mu Shui CSDN blog http://blog.csdn.net/zhoumushui
My GitHub: Zhou mu Shui's GitHub https://github.com/zhoumushui