jar加载不到SQL驱动

在idea里运行是可以正常登录的

我在idea里新建了一个文件夹lib,打包之后在项目.jar里也有这个文件夹,里面有sqljdbc42.jar

运行jar时提示com.microsoft.sqlserver.jdbc.SQLServerDriver

import  java.sql.*;
public class mysql {
    private static  Connection connection;
    private static  Statement statement;
    private static  ResultSet rs;
    public  static  Connection getConnection() throws Exception{
        try{
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            String url="jdbc:sqlserver://localhost:1433;DatabaseName=SA0326";

            String user="sa";
            String pwd="123456";
            connection = DriverManager.getConnection(url,user,pwd);
        }catch (Exception e){
            System.out.println(e);
        }finally {
            return connection;
        }
    }
    public  static  void close() throws  SQLException{
        if (rs != null){
            rs.close();
        }
        if(statement != null){
            statement.close();
        }
        if(connection != null){
            connection.close();
        }
    }
}

新建lib后有右键对lib执行add libary吗?