首页 > 技术文章 > 静态代码块

wangchuanfu 2017-04-20 09:59 原文

public class DBUtils {

    private static String url=null;
    private static String username=null;
    private static String password=null;
    
    static{
        try{
            Properties dBJavaPro=FileUtils.getProByFileName("jdbc_moblie.properties");
            url=dBJavaPro.getProperty("url").toString();
            username=dBJavaPro.getProperty("username").toString();
            password=dBJavaPro.getProperty("password").toString();
            Class.forName("com.mysql.jdbc.Driver");
        }catch(Exception e){
            e.printStackTrace();
        }
    }

}

 

//构造函数

public class MemberAvivaSSoAction extends BaseAction {
    private String key;
    private String getMobileUrl;
    private Long roleId;
    private Long rankId;

    public MemberAvivaSSoAction() {
        this.key = (String) PropertyConfigurer.getContextProperty("aviva.cofco.key");
        this.getMobileUrl = (String) PropertyConfigurer.getContextProperty("aviva.cofco.getMobileUrl");
        this.roleId =  Long.parseLong((String)PropertyConfigurer.getContextProperty("aviva.cofco.roleId"));
        this.rankId = Long.parseLong((String) PropertyConfigurer.getContextProperty("aviva.cofco.rankId"));
    }

 

推荐阅读