import java.sql.*;
//连接管理者
public class DBManager {
public DBManager() {
}
public static Connection getConnection() {
Connection con = null;
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433;dataBaseName=pubs",
"sa", "");
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
}
return con;
}
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10395457/viewspace-966582/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10395457/viewspace-966582/