import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class DbDemo { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try{ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection com = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;datebassname = XSDB;","sa","123"); System.out.println("连接成功!"); }catch(Exception e){ e.printStackTrace(); } } }