edit-icon download-icon

How to Build an ApsaraDB for RDS Java Eclipse Environment

Last Updated: Jul 13, 2016


  1. You can refer to the following method when using Java to develop ApsaraDB for RDS management and connection. The JDK 1.7 and later versions are recommended. As for the installation of Maven, you can Click to View.

  2. You can use MySQL Connector to connect Java of ApsaraDB for RDS MySQL (You can download MySQL Connector from Aliyun official website), and import the corresponding JAR packet to the build path. To download MySQL Connector, you can Click to View.

  3. Samples of ApsaraDB for RDS MySQL connection:

    import java.sql.Connection;

    import java.sql.DriverManager;

    import java.sql.ResultSet;

    import java.sql.SQLException;

    import java.sql.Statement;


    public class mysqlconnection {


    public static void main(String[] args) {

    Connection conn = null;

           String sql;      

           String url = "jdbc:mysql://rdsso9mgflpy9xu2nb5luo.mysql.rds.aliyuncs.com:3306?zeroDateTimeBehavior=convertToNull"

                   + "user=michael&password=password&useUnicode=true&characterEncoding=UTF8

           try {



           conn = DriverManager.getConnection(url);

           Statement stmt = conn.createStatement();

          String  sqlusedb="use test_5";


          int result1 = stmt.executeUpdate(sqlusedb);


           sql = "create table teacher(NO char(20),name varchar(20),primary key(NO))";

           int result = stmt.executeUpdate(sql);

           if (result != -1) {


               sql = "insert into teacher(NO,name) values('2016001','wangsan')";

               result = stmt.executeUpdate(sql);

               sql = "insert into teacher(NO,name) values('2016002','zhaosi')";

               result = stmt.executeUpdate(sql);

               sql = "select * from teacher";

               ResultSet rs = stmt.executeQuery(sql);

               System.out.println("Student ID\t name");

               while (rs.next()) {


                           .println(rs.getString(1) + "\t" + rs.getString(2));



       } catch (SQLException e) {

           System.out.println("MySQL operation error");


       } catch (Exception e) {


       } finally {

           try {


} catch (SQLException e) {

// TODO Auto-generated catch block








If the problem persists, contact AliyunAfter-Sales Technical Support.


Thank you! We've received your feedback.