package api;

import java.sql.Connection;
import java.sql.DriverManager;

public class MssqlJDBC {
    public static  String DBDRIVER="com.microsoft.sqlserver.jdbc.SQLServerDriver";
    public static  String DBURL="jdbc:sqlserver://192.168.20.122:1433;database={dbname};integratedSecurity=true;encrypt=false;trustServerCertificate=true;create=true";
    public static  String DBUSER="ljhyPortal2016";
    public static  String DBPASS="testliangjian@#!)2016";

    private static Connection conn = null;

    public static Connection getConn(String dbName){
        try{
            Class.forName(DBDRIVER);
            String url = DBURL.replace("{dbname}",dbName);
            conn = DriverManager.getConnection(url,DBUSER,DBPASS);
        }catch(Exception e){
            e.printStackTrace();
        }
        return conn;
    }
}
