1

I'm using the BoneCP connection pool library and basically everything works fine. But there is one thing that I am not 100 percent sure about:

I have a connection pool that is open during the whole runtime. Do I have to add a shutdown hook that closes the connection pool? Or could I just do nothing when the application exists?

The shutdown hook would look like this:

Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public final void run() {
        connectionPool.shutdown(); //shutdown the connection pool
    }
});

But it gives me a not very good looking log message that mixes up with my logging system because the shutdown hooks run cuncurrent. So I would not want to call this. Do I have to?

MinecraftShamrock
  • 3,504
  • 2
  • 25
  • 44
  • 1
    I personally expect that if the library needs a shutdown hook it should add it itself. I would do nothing here. – user207421 Mar 04 '14 at 00:31
  • Calling shutdown is recommended, see [here](http://stackoverflow.com/q/9327764/3080094) – vanOekel Mar 07 '14 at 18:33
  • It says I should close it if I don't need it any more. But I need it during runtime all the time. So If the CP is no longer needed the program will exit any way... – MinecraftShamrock Mar 07 '14 at 20:55

0 Answers0