保持数据库连接更好吗? [英] Is it better to hold database connections?

查看:46
本文介绍了保持数据库连接更好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为 bukkit 开发插件,其中很多都需要数据库连接.现在我在考虑是否只有一个插件来处理所有插件的连接会更好.

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?

推荐答案

最好有一个处理数据库的类/插件,但连接状态不应一直处于打开状态,确保连接处于打开状态仅用于查询所花费的时间.

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.

这篇关于保持数据库连接更好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆