K. D.
K. D.

Reputation: 4249

Is it better to hold database connections?

I'm currently developing plugins for bukkit and a lot of them need a database connection. Now I'm thinking about if could be better to have just one plugin that handles the connection for all plugins.

The question behind that is if it is good or not to keep a connection up even if there are no queries for some minutes (that may happen). Otherwise I would need to establish a new connection for each query?

Upvotes: 0

Views: 937

Answers (2)

0xCAFEBABE
0xCAFEBABE

Reputation: 5666

Many applications use connection pools to have a number of connections readily available to run queries over. It reduces the number of protocol re-negotiations that the database driver has to do. This is especially useful for applications that need fast access times to the underlying data, yet have larger downtimes between requests. E-Commerce applications like webshops are a good example.

Upvotes: 0

Ratna
Ratna

Reputation: 2319

It is a good idea to have one class/plugin for handling database, but the connection state should not be open all the time,make sure the connection is opened only for the time taken by the query.

Upvotes: 2

Related Questions