package util;
import java.sql.Connection;
import java.sql.DriverManager;
public class ConnDB {
public static String driver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
public static String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=temp";
public static String username="sa";
public static String password="";
public static Connection con=null;
public static Connection getConnection()
{
try {
Class.forName(driver);
con=DriverManager.getConnection(url,username,password);
System.err.println("链接成功");
} catch (Exception e) {
e.printStackTrace();
}
return con;
}
public static void main(String[] args) {
ConnDB.getConnection();
}
}