Yes, that works! thinks :)

------------------ 原始邮件 ------------------
发件人: "sunil yadav"<>;
发送时间: 2018年12月29日(星期六) 上午10:38
收件人: "user"<>;
主题: Re: How to keep information when submit topology

Keep it in config and access it in prepare/init method of your bolt. Only thing to ensure is the object needs to be serilizable.

On Fri, Dec 28, 2018 at 9:12 PM ChenBo <> wrote:
Hi All, I use storm-core  1.2.2, there is my problem.

I keep some information in Class static field before submit topology to Storm. But after I found when topology run, all those information lost.

I think maybe it's because all class will be reload after submit. So Is there anyway to store some information before submit topology and also can get back those infor when topolog run?

And there is my code.

 * the class is used to init mysql connection pool
public class DataBaseManger {
    private static final Logger logger = LoggerFactory.getLogger(DataBaseManger.class);
    private static BoneCP comboPooledDataSource;

    public static boolean init(String url, String user, String password) {
        try {
        } catch (ClassNotFoundException e) {
            return false;

        try {
            BoneCPConfig config = new BoneCPConfig();
            comboPooledDataSource = new BoneCP(config);
        } catch (SQLException e) {
            return false;
        return true;

    public static synchronized Connection getConnection() throws SQLException {
        return comboPooledDataSource.getConnection();

 * submit topology, and before that use local information to init the mysql connection pool
    public static void main(String[] args) throws Exception {
        LocalConfig localConfig = new LocalConfig(args);

        DataBaseManger.init(LocalConfig.getDbUrl(), LocalConfig.getDbUser(), LocalConfig.getDbPw());

        StormTopology topology = createTopology(localConfig);
        Config config = getTopologyConfig(localConfig);

        StormSubmitter.submitTopology(localConfig.getTopologyName(), config, topology);

In Blot use DataBaseManger.getConnection() to get connection. But it's get NullPointException. that turns out comboPooledDataSource is null.
So I am wounder is there anyway to keep mysql connection information after submit topology?

Any help is appreciated.