This post is a continuation of the application of the SAE log view for Sina Cloud, the previous post.
Before reading and writing to the cloud database MySQL, it is necessary to explain that when using the database on the Sina cloud platform. The platform defaults to creating a separate database instance for each application. Create a variety of table tables that we need in this instance. Of course, setting enables multiple apps to share the same DB instance.
The following is an application join database service step.
First, initialize MySQL through the console
1. Enter the shared MySQL under the left Side database service sub-item of Sina Cloud Console
2. then the page appears
3. Click Initialize Mysqlbutton page appears
4, click the first box (through the link in the second box can be described at the beginning of this article to enable multiple applications to share the same DB instance ) in the management MySQL link, you can go to create table page
The contents of the first box and the second box form the data in the database connection code. host name and database name
connection= (Connection) drivermanager.getconnection ("Jdbc:mysql://w.rdc.sae.sina.com.cn:3307/app_geekzhou", " Username "," password ");
in the code above
username and password are replaced with the app's access key and secret key respectively.
5, fill in the table name, here is the name test. For example, number of fields 4. Go to Next step
6. After completion of filling. Be sure to click the Save button instead of the Run button to run the button to add several more fields.
7, after saving to enter such as the following page
So far the database and tables have been created.
Second, the database complete connection code
public static Connection getconnection () {Connection Connection = Null;try{class.forname (" Org.gjt.mm.mysql.Driver "); connection= (connection) drivermanager.getconnection (" jdbc:mysql:// W.rdc.sae.sina.com.cn:3307/app_reporttable "," Access Key "," Secret Key "); Connection.setautocommit (false);} catch (Exception ex) {ex.printstacktrace ();} return connection;}
iii. Results of implementation
Cloud application Development Sina SAE read-write cloud database MySQL