All Products
Document Center

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://;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);        



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