Java examples for java.sql:SqlServer
get MS SQL Server 2005 Connection
//package com.java2s; import java.sql.*; public class Main { public static Connection getMSSQL2005Con(String server, String db, String uid, String pwd) { try {//from w w w . j a v a 2 s.c om //Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); // set this to a MS SQL Server String database = "jdbc:sqlserver://" + server + ":8081;"; database += "databasename=" + db + ";user=" + uid + ";password=" + pwd + ";"; // now we can get the connection from the DriverManager return DriverManager.getConnection(database); } catch (Exception e) { e.printStackTrace(); return null; } } }