edit-icon download-icon

Connecting Java to the ApsaraDB for RDS SQL Server

Last Updated: May 04, 2018

 

Version requirements: JDK 1.7 and later.

Download a proper JAR package based on the requirements at the Microsoft official website. Click here to download.

  

The following code snippet is used to import the JDK to the project by using sqljdbc42.jar:

 String userName = “user”;  //Default user name   

 String userPwd = “pass321”;   //Password   

 String url=”jdbc:sqlserver://rds.sqlserver.rds.aliyuncs.com:3433;DatabaseName=dbtest”;   

 java.sql.Connection  dbConn = DriverManager.getConnection(url, userName, userPwd);   

 Object sta = dbConn.createStatement();   

 String sql = “create table student”+ “     (id int , name varchar(10))”;          

 int row = ((Statement) sta).executeUpdate(sql);        

 System.out.println(“successfully”);

  

If the problem persists, contact Alibaba Cloud After-Sales Technical Support.

Thank you! We've received your feedback.