Cloud application Development Sina SAE read-write cloud database MySQL

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.