package utils;
import java.sql.*;
/**
* Created by yinus on 2016/4/4.
*/
public class Dbtuil {
private static final String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String dbURL="jdbc:sqlserver://localhost:port;DatabaseName=tableName";
private static final String userName="usrName";
private static final String userPwd="password";
private static Connection connection = null;
static{
try {
Class.forName(driverName);
connection=DriverManager.getConnection(dbURL,userName,userPwd);
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public static Connection getConnection(){
return connection;
}
public static void close() throws SQLException {
connection.close();
}
}