package com.it.test; import java.sql.Connection; import java.sql.DriverManager; public class Sip { public static void main(String[] args) { String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; String dbURL = "jdbc:sqlserver://1127.0.0.1\sip:1433;DatabaseName=你的数据库名称"; String userName = "sa(你的管理员名称)"; String userPwd = "你的密码"; try { Class.forName(driverName); Connection dbConn = DriverManager.getConnection(dbURL, userName, userPwd); System.out.println("success!"); } catch (Exception e) { e.printStackTrace(); System.out.print("fail!"); } } }